Created
October 14, 2020 19:50
-
-
Save drunkensouljah/e96cea3a9817120184d915525b2a5388 to your computer and use it in GitHub Desktop.
Get JSON Data with JavaScript Fetch API
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
| // Replace ./data.json with your JSON feed | |
| fetch('./data.json') | |
| .then((response) => { | |
| return response.json() | |
| }) | |
| .then((data) => { | |
| // Work with JSON data here | |
| console.log(data) | |
| }) | |
| .catch((err) => { | |
| // Do something for an error here | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment