Possible Unhandled Promise Rejection (id:0) Error: network error in react native
import React, {Component} from 'react';
import {View,Text} from 'react-native';
import axios from 'axios';
class AlbumList extends Component {
state = {albums: []};
componentWillMount() {
axios.get('https://rallycoding.herokuapp.com/api/music_albums')
.then(response=>this.setState({albums: response.data}));
}
renderAlbums() {
return this.state.albums.map(album => <Text>{album.title}</Text>);
}
render() {
console.log(this.state);
return(
<View>
{this.renderAlbums()}
</View>
);
}
};
export default AlbumList;
// I can't load my data from the given link, also in debugging mode there's only //one state created which has empty values and no other data can be visible in //console so help me in fetching the data
Here is screenshot of error I'm getting
I think you should try reload app/reinstall app/restart emulator/try on new emulator. I also have had multiple generic network error
s using just regular fetch
, and they were all related to just the emulator being weird.