Skip to content

Instantly share code, notes, and snippets.

@nicolaisimonsen
Created February 17, 2024 13:35
Show Gist options
  • Save nicolaisimonsen/d94dee3196448b455f780da07c9382ea to your computer and use it in GitHub Desktop.
Save nicolaisimonsen/d94dee3196448b455f780da07c9382ea to your computer and use it in GitHub Desktop.
fetch async await
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