Skip to content

Instantly share code, notes, and snippets.

@dbani-dev
Last active July 10, 2017 05:11
Show Gist options
  • Save dbani-dev/c4a710518498d19013be9c6f4f2de1f4 to your computer and use it in GitHub Desktop.
Save dbani-dev/c4a710518498d19013be9c6f4f2de1f4 to your computer and use it in GitHub Desktop.
class ExampleComponent extends Component {
constructor() {
super();
}
// When the ExampleComponent is ready
componentDidMount() {
// Get data from API
fetch('https://swapi.co/api/people/?page=1')
.then(res => res.json())
.then(jsonData => {
console.log(jsonData) // jsonData should be data object (count, next, previous, results etc)
});
}
render() {
return (
<div>Some component</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment