npm packet address
https://www.npmjs.com/package.
the code is as follows:
module.exports = {
post: async function(url, headers, postBody) {
const _self = this;
var response = [];
try {
const response = await fetch(url, {
method: "POST",
headers: headers,
body: postBody,
mode: "cors",
credentials: "include"
})
return await response.json();
} catch (e) {
console.log("Oops, error", e)
}
},
get: async function(url, headers, postBody) {
const _self = this;
var response = [];
try {
const response = await fetch(url, {
method: "GET",
body: postBody,
headers: headers,
mode: "cors",
credentials: "include"
})
return await response.json();
} catch (e) {
console.log("Oops, error", e)
}
}
}