Created
February 17, 2024 13:35
-
-
Save nicolaisimonsen/d94dee3196448b455f780da07c9382ea to your computer and use it in GitHub Desktop.
fetch 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
async function getBlogPost() { | |
const response = await fetch( | |
"https://jsonplaceholder.typicode.com/posts/?userId=1" | |
); | |
const data = await response.json(); | |
return data; | |
} | |
const blogPosts = getBlogPost(); | |
blogPosts.then((value) => console.log(value)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment