I can't seem to get Android to pass any options when it works fine on iOS. It appears to go to the endpoint and drop the method, headers and body. I don't know for sure because when I added some of the code I mention below to debug, it works.
let data = JSON.stringify({
appKeyLookup: CONSTANTS.APP_KEY_LOOKUP,
username: username,
password: password,
});
try {
let response = await fetch(CONSTANTS.API_URL + 'login/', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
},
body: data,
});
let responseJSON = await response.json();
The really weird thing is, that if I add
const _XHR = GLOBAL.originalXMLHttpRequest ? GLOBAL.originalXMLHttpRequest : GLOBAL.XMLHttpRequest
XMLHttpRequest = _XHR
To the entry point and then install the chrome extension Allow-Control-Allow-Origin:*
It works fine. So it seems it has something to do with CORS but I am not sure.
I am on React Native 0.56.0