Created
September 9, 2017 05:37
-
-
Save milon87/f391e54e64e32e1626235d4dc4d16dc8 to your computer and use it in GitHub Desktop.
how to use x-www-form-urlencoded in react native
This file contains hidden or 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
var details = { | |
'userName': '[email protected]', | |
'password': 'Password!', | |
'grant_type': 'password' | |
}; | |
var formBody = []; | |
for (var property in details) { | |
var encodedKey = encodeURIComponent(property); | |
var encodedValue = encodeURIComponent(details[property]); | |
formBody.push(encodedKey + "=" + encodedValue); | |
} | |
formBody = formBody.join("&"); | |
fetch('http://identity.azurewebsites.net' + '/token', { | |
method: 'POST', | |
headers: { | |
'Accept': 'application/json', | |
'Content-Type': 'application/x-www-form-urlencoded' | |
}, | |
body: formBody | |
}) |
Really a great solution ever
Thanks for the solution.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mguay22
Object.entries(form).forEach((key, value) => {
... should be:
Object.entries(form).forEach(([key, value]) => {