2

I want to use axios in my app project but get this error

network request failed

my code is:

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

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

      alert(response)

  });

and I tested this but it does not work too

axios:

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

   }).catch(function(error) {
       // alert(error)
       console.warn(error)
   });
1
  • Do you get this error on ios? Commented Jul 23, 2017 at 13:07

1 Answer 1

1

This will help you.

state = { abc:[] };

componentWillMount() {

 axios.get('url')//lowercase a
.then(response => this.setState({abc:response.data})).catch((error) => {
     console.error(error);
 });
}
Sign up to request clarification or add additional context in comments.

1 Comment

Can you explain why? I'm having the same problem and this doesn't help me at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.