reactNative-解决react native使用fetch函数 Network request failed 问题

解决react native使用fetch函数Network request failed问题

最近公司新开发一个app, 用react native架构好后,用xcode模拟器打开app,对接登陆接口,发现老师fetch 方法,提示Network request failed这个报错;经百分百确认不是API问题后,百度后找到了问题所在,问题得以解决:
  • ios9默认https请求,http需要配置info.plist;

  • 解决方法

    • 1、在Info.plist中添加 NSAppTransportSecurity 类型 Dictionary ;
    • 2、在Info.plist中的App Transport Security Settings中添加Allow Arbitrary Loads,类型为Boolean,值为yes
      enter image description here
  • 设置后
    enter image description here

原文地址:https://www.cnblogs.com/frankltf/p/6878987.html