import 'whatwg-fetch';
// fetch polyfill
const url = <code>https://abc.xgqfrms.xyz/some-url</code>;
const headers = new Headers({
'Content-Type': 'text/plain',
'X-My-Custom-Header': 'CustomValue'
});
const datas = JSON.stringify(
{
user: "username",
pwd: "password"
}
);
const method = <code>POST</code>;
const request = new Request(url, {
headers: headers,
method: 'POST',
mode: 'cors',
redirect: 'follow',
body: datas
});
fetch(
request
).then(
(response) => response.json()
).catch(
(err) => {
console.log(<code>err</code>, err);
throw new Error("Whoops, An Error occurred!");
}
);
Created
January 14, 2018 13:43
-
-
Save xgqfrms-GitHub/64972e969d7491a7f845b9d69a9ba743 to your computer and use it in GitHub Desktop.
whatwg-fetch & fetch polyfill
Author
xgqfrms-GitHub
commented
Jan 14, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment