componentDidMount() {
const url = (Remote Http URL)
;
this.setState({ loading: true });
fetch(url)
.then(res => res.json())
.then(res => {
this.setState(
{
loading: false,
error: res.error || null,
data1: res
},
()=> {
console.log(res);
}
);
})
.catch(error => {
this.setState({ error, loading: false }, () => {
console.log(error);
});
});
}
I am trying to access Remote HTTP Api on my local machine. The API is working perfectly on Postmant as well as on Chrome in my local machine. But When make Fetch call using Expo React Native Fetch I am getting the following error:
Network request failed
- node_modules\whatwg-fetch\dist\fetch.umd.js:473:29 in xhr.onerror
- node_modules\event-target-shim\dist\event-target-shim.js:818:39 in EventTarget.prototype.dispatchEvent
- node_modules\react-native\Libraries\Network\XMLHttpRequest.js:574:29 in setReadyState
- node_modules\react-native\Libraries\Network\XMLHttpRequest.js:388:25 in __didCompleteResponse
- node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:190:12 in emit
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:436:47 in __callFunction
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111:26 in __guard$argument_0
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:384:10 in __guard
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:110:17 in __guard$argument_0
- [native code]:null in callFunctionReturnFlushedQueue
For your information I am trying to run the app on an Latest Android Device.