Created
March 16, 2018 06:33
-
-
Save jonathanmv/ab501e408d227cadcb466a0501fdbb1b to your computer and use it in GitHub Desktop.
To check if await can be chained to then or catch
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
const l = console.log.bind(console) | |
const a = () => new Promise(resolve => setTimeout(() => resolve('done'), 1000)) | |
const b = () => new Promise((_, reject) => setTimeout(() => reject('error'), 1000)) | |
const c = async () => { | |
(await a()).then(l) | |
(await b()).catch(l) | |
} | |
c().then(() => l(`it can be done!!`)) | |
.catch(({message}) => l(`Sorry dude: ${message}`)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment