I’m trying to send a GET request to the Facebook Graph API using fetch:
var url = "https://graph.facebook.com/v2.7/"
+FACEBOOK_APP_ID
+"?fields=context"
+"{friends_using_app{id,name,picture.type(normal)}}"
+"&access_token="+_this.props.user.facebook_access_token;
fetch(url)
.then((response) => response.json())
.then((responseJson) => {
console.log(responseJson);
})
.catch(function(error) {
console.log(error);
});
But I’m getting TypeError: Network request failed(…)
in the JavaScript console. This only happens on iOS, it works fine on Android.
As far as I know, iOS on react native allows HTTPS requests by default, so this shouldn’t require any config.
I am able to make a request to https://google.com using fetch
, and I am able to view the result of the above request in safari when I print the url
var and paste it directly.
Don’t seem to be able to find anything similar, but sorry if this is a duplicate.
3
Answers
Maybe, a retry might work:
add this to Info.plist
read more here https://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/
This isn’t quite right. Any old https connection isn’t good enough for App Transport Security, so you might still need to do some configuration. Here’s the docs on what exactly is required to satisfy ATS without config:
I’ve also created a video tutorial on how to make network requests for your react native app: http://codecookbook.co/post/how-to-make-network-requests-in-react-native/