Last active
December 7, 2018 16:37
-
-
Save MarkNewcomb1/450d67de1009b757ddf6c593f48cb4f3 to your computer and use it in GitHub Desktop.
Async with react
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const apiUrl = './dinosaurs.json' | |
| // constructor stuff | |
| componentDidMount() { | |
| this.fetchProfiles() | |
| } | |
| async fetchProfiles() { | |
| const response = await fetch(apiUrl) | |
| const json = await response.json() | |
| console.log(json) | |
| this.setState({ | |
| profiles: json | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment