环境:
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;