React Native fetch() Network Request Failed
Full error message
When I create a brand new project using react-native init (RN version 0.29.1) and put a fetch in the render method to the public facebook demo movie API, it throws a Network Request Failed. There is a very useless stack trace and I can't debug network requests in the chrome console. Here is the fetch I'm sending:
fetch('http://facebook.github.io/react-native/movies.json')
.then((response) => response.json())
.then((responseJson) => {
return responseJson.movies;
})
.catch((error) => {
console.error(error);
});Solutionsource: stackoverflow \u2197
The problem here is that iOS does not allow HTTP requests by default, only HTTPS. If you want to enable HTTP requests add this to your info.plist: <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
API access
Get this solution programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/error/c233446e2580e59ce37b3d3b90170536d99b87339cca1e5fefeb9af758fb51fdhash \u00b7 c233446e2580e59ce37b3d3b90170536d99b87339cca1e5fefeb9af758fb51fd