07-05-2018 03:10
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

Runner
61
2
22
07-05-2018 03:10
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I am using an API that expects POST data to be form encoded ie. "Content-Type": "application/x-www-form-urlencoded"
I am trying to use fetch but I am maybe missing something as I am stuck as how to best send the data.
var data = { 'grant_type' : 'password', 'client_id' : clientID, 'client_secret' : clientSecret, 'username' : username, 'password' : password, } fetch(url, { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: JSON.stringify(data) }) .then((response) => {return response.json()}) .then((data) => { func.logString(data);
I had previously gotten around this issue by using the URLSearchParams interface that worked fine in the simulator but is unsupported in iOS (so it kept failing on my device which is connected to my iPhone X)
So any ideas on how to proceed ? I am stuck

0 REPLIES 0
