使用 axios 和 fetch in react native 时出现网络错误

Network error in use of axios and fetch in react native

我想在我的应用程序项目中使用 axios 但出现此错误

network request failed

我的代码是:

  fetch('https://facebook.github.io/react-native/movies.json').then(function(response) {

      alert(response.data);
  }).catch(function(response) {

      alert(response)

  });

我对此进行了测试,但它也不起作用

axios:

   Axios.get('https://facebook.github.io/react-native/movies.json').then(function(response) {

   }).catch(function(error) {
       // alert(error)
       console.warn(error)
   });

这对你有帮助。

state = { abc:[] };

componentWillMount() {

 axios.get('url')//lowercase a
.then(response => this.setState({abc:response.data})).catch((error) => {
     console.error(error);
 });
}