Skip to content

Instantly share code, notes, and snippets.

@tmanOC
Created January 27, 2020 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmanOC/39067bc71e54caa4e7164c6d2f9bf1db to your computer and use it in GitHub Desktop.
Save tmanOC/39067bc71e54caa4e7164c6d2f9bf1db to your computer and use it in GitHub Desktop.
Promises with async await pretty much how I like it
var err, result
[err, result] = await methodThatReturnsAPromise().then(res => [null, res], error => [error]).catch(error => {err = error})
if(err != null) {
handleAnyExceptions(err)
} else if(result != null) {
handleResult(result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment