This has me stumped. I am working on the following:
const testFetch = () => {
console.log("testFetch");
fetch(`${baseurl}/${requrl}`, {
method: "POST",
body: JSON.stringify({ foo: "bar" }),
headers: {
"Content-Type": "application/json; charset=utf-8",
Accept: "*/*",
"Cache-Control": "no-cache",
},
})
.then((response) => {
console.log("response", response);
})
.catch((err) => {
console.log("error", err);
});
};
The server will return a 401 Unauthorized for this call. The promise never resolves in iOS (it does in Android). I.e. I never get to the response or error logging. Here it gets weird IMO:
- When I remove the body payload the promise resolves
- When I change the url to a non existent path the promise resolves (with a 404 not found)
I’m on Expo 15.0.7 and React Native 0.74.2. I’ve tried Axios, Apisauce and XMLHttpRequest to no avail. With postman I get a perfect response. It’s not cors related. This happens on Expo Go in the iOS simulator and on an iOS device. An Android device had no issue with this code. Having spent more than 24 hours on debugging this I turn the you. Thanks for your time.