Skip to content

Instantly share code, notes, and snippets.

@joduplessis
Created September 13, 2017 13:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joduplessis/efda3f43249aa7a45b6267fda5bdc77d to your computer and use it in GitHub Desktop.
Save joduplessis/efda3f43249aa7a45b6267fda5bdc77d to your computer and use it in GitHub Desktop.
Example of making an async React Native call to a .NET Web API 2 project.
/*
* Example of making an async React Native call to a .NET Web API 2 project.
* Helped with this issue a few times now.. Note the content type.
*/
(async () => {
// Make the API call
fetch(constants.API_ROUTE+'Token', {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: 'grant_type=password&username=USERNAME&password=PASSWORD'
})
.then(function(response) {
// Do something cool
})
.catch(function(err) {
// Tell the user something is broken
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment