Skip to content

Instantly share code, notes, and snippets.

@xjamundx
Last active July 21, 2016 21:44
Show Gist options
  • Save xjamundx/c7454a0072fb42f70ec5548759c2678a to your computer and use it in GitHub Desktop.
Save xjamundx/c7454a0072fb42f70ec5548759c2678a to your computer and use it in GitHub Desktop.
// rely on try/catch around the awaited Promise
async function doSomething() {
try {
let data = await getData()
} catch (err) {
console.error(err)
}
}
// add a catch handler
function doSomething() {
return getData().catch(err => {
console.error(err)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment