Created
August 19, 2015 10:48
-
-
Save deanhume/f9a338d12aeb983b15be to your computer and use it in GitHub Desktop.
A simple POST request using the fetch API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank You great and simple explanation.