首页 > 解决方案 > TypeError:网络请求失败。安卓

问题描述

使用 http:// 请求获取错误并且使用 https:// 其工作正常

例如

getData(){
  fetch('http://facebook.github.io/react-native/movies.json', {
  method: 'GET',
  headers: {
    Accept: 'application/json',
    'Content-Type': 'application/json',
  }
})
.then((response) => response.json())
    .then((responseJson) => {
       console.log('responseJson >>>>'+JSON.stringify(responseJson));

    })
   .catch((error) => {
      console.error('error>>>>>'+error);
    });

}

反应版本“反应”:“16.6.3”,“反应原生”:“0.58.5”

** 设备有网络连接,因为设备浏览器网页正在加载。

标签: react-native

解决方案


推荐阅读