Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save eclectic-coding/3474ca942ae1fa62cc4dfa90c35ed824 to your computer and use it in GitHub Desktop.
Save eclectic-coding/3474ca942ae1fa62cc4dfa90c35ed824 to your computer and use it in GitHub Desktop.
Async/await without try/catch in JavaScript
async function fetchAndUpdatePosts() {
const posts = await fetchPosts().catch(() => {
console.log('error in fetching posts');
});
if (posts) {
doSomethingWithPosts(posts);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment