加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 03:26:36 所属栏目:百科 来源:网络整理
导读:环境: 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.

环境:

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读