postData = (url = '', data = {}, fetchmethod = 'POST', fetchmode) => {
const esc = encodeURIComponent;
var query = Object.keys(data)
.map(k => esc(k)+ '=' + esc(data[k]))
.join('&');
return fetch(url, {
method: fetchmethod, // *GET, POST, PUT, DELETE, etc.
mode: fetchmode, // no-cors, cors, *same-origin
cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
credentials: "same-origin", // include, same-origin, *omit
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: query
})
}
Created
September 17, 2018 17:25
-
-
Save andrit/82c2c107d352bd4ae3adc478bb584548 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment