Created
April 27, 2019 13:48
-
-
Save deepal/71c964261dc72c75f226e40a71ad36e3 to your computer and use it in GitHub Desktop.
This file contains 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
function myAsyncFunction() { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
reject(new Error('oops')) | |
}, 1000); | |
}); | |
} | |
(async() => { | |
try { | |
await myAsyncFunction(); | |
// happy path | |
} catch (err) { | |
// handle error | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment