/
test.js
60 lines (56 loc) · 1.56 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
var mdpAPI = require("./index");
const fetch = require("node-fetch");
var myAPI = new mdpAPI({
logEnabled: true,
// logPrefix: "MySimpleAPI >",
// logStyle: "color: red",
includeDetails: true,
middlewareFunctions: {
200: function (res) {
console.info("WE HAVE 200", res);
},
403: function (res) {
console.info("WE HAVE 403", res);
},
},
fetchLib: fetch, // passing the fetchLibrary that we want to use
// fetchLibName: "axios",
});
myAPI.setMiddleware(200, function (res) {
console.info("------------- WE HAVE 200 statusText", res.statusText);
});
myAPI.removeMiddleware(200);
// myAPI.get(
// "https://jsonplaceholder.typicode.com/posts/1",
// null,
// function (data) {
// console.info("data >>> ", data);
// },
// function (error) {
// console.error("error >>> ", error);
// }
// );
myAPI
.post(
"http://localhost:5000/challenges-fba64/us-central1/webApi/api/v1/graphql",
{
query: `{
users {
key,
disabled,
email,
displayName,
provider,
level,
avatar
}
}
`,
}
)
.then((result) => {
console.info("result => ", result);
})
.catch((err) => {
console.error("err => ", err);
});