Skip to content

Instantly share code, notes, and snippets.

@linux08
Created November 4, 2018 23:23
Show Gist options
  • Save linux08/e910237b4e0c9b7411bac46a8d1ae980 to your computer and use it in GitHub Desktop.
Save linux08/e910237b4e0c9b7411bac46a8d1ae980 to your computer and use it in GitHub Desktop.
componentDidMount() {
const config = {
method: 'GET',
headers: {
Accept: 'application/json'
},
};
fetch('http://10.0.2.2:5000/images', config)
.then((resp) => resp.json())
.then((res) => {
this.setState({
images: res,
fetchLoading: false
})
})
.catch((err) => {
console.log('err', err.message)
this.setState({
fetchLoading: false,
error: err.message
});
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment