I am fetching data via a localhost api using axios in a react native app. If I run it on my web browser, it works fine and the data gets fetched. If I run it on my android emulator then I get a network error.
Here is my code:
componentDidMount() {
axios.get('http://laravelapi.build/api/art_objects')
.then((res) => {
this.setState({
isLoading: false,
dataSource: res.data
})
})
.catch((err) => {
alert("Error fetching data!");
});
}