Created
September 19, 2019 09:39
-
-
Save konstantinmuenster/b884346b50f7f65deada036c7150d159 to your computer and use it in GitHub Desktop.
Understanding Async/Await - Resolved Example
This file contains 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 fetchData = async (url) => { | |
try { | |
const response = await fetch(url); | |
const data = await response.json(); | |
return data; | |
} catch(error) { | |
// Handle errors as needed | |
} | |
} | |
fetchData("https://example.com/posts") | |
.then( json => console.log(json) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment