Skip to content

Instantly share code, notes, and snippets.

@laere
Created February 6, 2016 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laere/f9236a0f3e943de2e39a to your computer and use it in GitHub Desktop.
Save laere/f9236a0f3e943de2e39a to your computer and use it in GitHub Desktop.
// THIS WILL RETURN API JSON DATA BEFORE FIRST RENDER
componentDidMount: function() {
fetch('http://swapi.co/api/people')
.then(function(response) {
return response.json
})
.then(function(json) {
this.setState({ data: json });
})
.catch(function(err) {
console.log(err);
})
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment