您的位置:首页 > Web前端 > React

react native下fetch ios9报network request failed的问题

2016-07-26 13:47 459 查看
环境:

RN: 0.28

iOS: 9

xcode: 7.0.1

现象:

执行以下语句时:

fetch('http://facebook.github.io/react-native/movies.json')
.then((response) => response.json())
.then((responseJson) => {
return responseJson.movies;
})
.catch((error) => {
console.error(error);
});


总是报错:

Network
Request Failed
.

查了一堆资料,最后解决:

http需要配置info.plist,具体配置如下:

1、在Info.plist中添加 NSAppTransportSecurity 类型 Dictionary ;

2、在 NSAppTransportSecurity 下添加 NSAllowsArbitraryLoads 类型Boolean ,值设为 YES;

参考:
http://www.codes51.com/article/detail_2177325.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: