Skip to content

Instantly share code, notes, and snippets.

@deanhume
Created August 19, 2015 10:48
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save deanhume/f9a338d12aeb983b15be to your computer and use it in GitHub Desktop.
Save deanhume/f9a338d12aeb983b15be to your computer and use it in GitHub Desktop.
A simple POST request using the fetch API
fetch(url, {
method: 'POST',
headers: {
'auth': '1234'
},
body: JSON.stringify({
name: 'dean',
login: 'dean',
})
})
.then(function (data) {
console.log('Request success: ', data);
})
.catch(function (error) {
console.log('Request failure: ', error);
});
@rakaar
Copy link

rakaar commented Aug 6, 2020

@almdhhish

You need to enable CORS on your server-side application. Please check it

@AndreyPootMay
Copy link

@rakaar where can I find the CORS Documentation?

@rpralica
Copy link

Thank You great and simple explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment