Created
June 13, 2021 14:49
-
-
Save kkroesch/a26e648ab489a84756c09853975bdd05 to your computer and use it in GitHub Desktop.
Load JSON data with async/await
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
let results; | |
const DEBUG = true; | |
const load_data = async () => { | |
try { | |
const url = "https://httpbin.org/json" | |
const response = await fetch(url) | |
results = await response.json() | |
if (DEBUG) console.log(response.ok) | |
if (DEBUG) console.log(results.slideshow) | |
} catch (error) { | |
if (DEBUG) console.error(error.message) | |
} | |
} | |
load_data() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment