Last active
July 23, 2017 02:09
-
-
Save johndaley-me/5c29cce66cba1ea81b66f3bc80ae2fc4 to your computer and use it in GitHub Desktop.
Promise vs await
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
// Promise | |
doSomethingAsync | |
.then((value) => console.log(value)); | |
.catch((error) => console.log(error)); | |
// or instead use await | |
try { | |
const value = await doSomethingAsync(); | |
console.log(value); | |
} catch (error) { | |
console.log(error); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment