Skip to content

Instantly share code, notes, and snippets.

@johndaley-me
Last active July 23, 2017 02:09
Show Gist options
  • Save johndaley-me/5c29cce66cba1ea81b66f3bc80ae2fc4 to your computer and use it in GitHub Desktop.
Save johndaley-me/5c29cce66cba1ea81b66f3bc80ae2fc4 to your computer and use it in GitHub Desktop.
Promise vs await
// 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