I am creating my 1st rect native app. Running on OSX using OS11 Iphone 6 simulator. Getting below error in https fetch call. Using XCode 9.
ExceptionsManager.js:73 TypeError: Network request failed
at XMLHttpRequest.xhr.onerror (fetch.js:441)
at XMLHttpRequest.dispatchEvent (event-target.js:172)
at XMLHttpRequest.setReadyState (XMLHttpRequest.js:548)
at XMLHttpRequest.__didCompleteResponse (XMLHttpRequest.js:381)
at XMLHttpRequest.js:487
at RCTDeviceEventEmitter.emit (EventEmitter.js:181)
at MessageQueue.__callFunction (MessageQueue.js:306)
at MessageQueue.js:108
at MessageQueue.__guard (MessageQueue.js:269)
at MessageQueue.callFunctionReturnFlushedQueue (MessageQueue.js:107)
React component fetch code. (which is sample code from react-native official example)
getMoviesFromApiAsync() {
return fetch('https://facebook.github.io/react-native/movies.json')
.then((response) => response.json())
.then((responseJson) => {
return responseJson.movies;
})
.catch((error) => {
console.error(error);
});
}
Do i really need to update info.pllist to enable Allow Arbitrary Loads ? I tried enabling that too once but did not work.
Package.json { "name": "rnstarter", "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest" }, "dependencies": { "react": "16.0.0-beta.5", "react-native": "^0.49.1" }, "devDependencies": { "babel-jest": "21.2.0", "babel-preset-react-native": "4.0.0", "jest": "21.2.1", "react-test-renderer": "16.0.0-beta.5" }, "jest": { "preset": "react-native" } }
After disconnecting from my employer's network it started working. Strange that i can hit facebook api using my browser even when i am connected to employer's network.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.