Error in Axios get - React Native [closed]

closed. this question is out of scope and is not currently accepting answers.

want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 12 days ago .

improve this question

I'm doing a React Native course and I'm not able to make an HTTP request using axios.

This is my code:

import React, { Component } from 'react'
import { View } from 'react-native'

import axios from 'axios'
import Itens from './Itens'

class ListaItens extends Component {
  componentWillMount () {
    axios.get('http://faus.com.br/recursos/c/dmairr/api/itens.html')
      .then(response => { console.log(response) })
      .catch((error) => console.log('Erro ao recuperar os dados ' + error))
  }
  render () {
    return (
      <View>
        <Itens />
        <Itens />
        <Itens />
      </View>
    )
  }
}
export default ListaItens

And the error return in catch is just Network Error

I saw that some people had the problem solved when the service to be contacted was on localhost

I'm using the Android emulator to do the tests and I don't know if any configuration has to be done on it for the request to work, but I can use the internet with it normally.

Author: Bacco, 2019-03-28