Last active
September 19, 2019 19:13
-
-
Save konstantinmuenster/c4137acafa209a60c2dcfac4edbea54b to your computer and use it in GitHub Desktop.
Understanding Async/Await (Medium) - 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"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment