Skip to content

Instantly share code, notes, and snippets.

@dbayarchyk
Created October 1, 2019 13:14
Show Gist options
  • Save dbayarchyk/b43872a25e20a07ac3eeec9432c74ef9 to your computer and use it in GitHub Desktop.
Save dbayarchyk/b43872a25e20a07ac3eeec9432c74ef9 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