Skip to content

Instantly share code, notes, and snippets.

@dbayarchyk
Last active October 1, 2019 13:23
Show Gist options
  • Save dbayarchyk/484b49cfe35659c5985c8d93dd6a8bc9 to your computer and use it in GitHub Desktop.
Save dbayarchyk/484b49cfe35659c5985c8d93dd6a8bc9 to your computer and use it in GitHub Desktop.
Async/await without try/catch in JavaScript
async function fetchAndUpdatePosts() {
let posts;
try {
posts = await fetchPosts();
} catch {
console.log('error in fetching posts');
}
if (!posts) {
return;
}
try {
await updatePosts();
} catch {
console.log('error in updating posts');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment