My api doesn't work on physical device Android, I checked other api, they work, only mine does not work. Everything works on the emulator.
if I add for debugg
GLOBAL.XMLHttpRequest = GLOBAL.originalXMLHttpRequest || GLOBAL.XMLHttpRequest;
to code, api starts working, although the data comes already an object and not json.
How can I make this api work correctly on my physical device, or using this command for debugging might be the right solution? I'm using axios for making api request
Code :
const data = await axios
.get(`https://MY_API`, {
headers: {
Host: 'MY_API',
Accept: '*/*',
'User-Agent':
'myApp/7.6.2 (iPhone; iOS 12.4.5; Scale/2.00)',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'en-US;q=1, ru-RU;q=0.9',
Connection: 'close',
},
})
.then(books => {
(logic)
})
.catch(err => {
console.log(err);
});
My error:
Error: Network Error
at createError (createError.js:16)
at EventTarget.handleError (xhr.js:83)
at EventTarget.dispatchEvent (event-target-shim.js:818)
at EventTarget.setReadyState (XMLHttpRequest.js:575)
at EventTarget.__didCompleteResponse (XMLHttpRequest.js:389)
at XMLHttpRequest.js:502
at RCTDeviceEventEmitter.emit (EventEmitter.js:189)
at MessageQueue.__callFunction (MessageQueue.js:425)
at MessageQueue.js:112
at MessageQueue.__guard (MessageQueue.js:373)
P.C Sorry for my bad English ;)