Last active
October 1, 2019 13:23
-
-
Save dbayarchyk/484b49cfe35659c5985c8d93dd6a8bc9 to your computer and use it in GitHub Desktop.
Async/await without try/catch in JavaScript
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 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