Created
January 27, 2020 06:42
-
-
Save tmanOC/39067bc71e54caa4e7164c6d2f9bf1db to your computer and use it in GitHub Desktop.
Promises with async await pretty much how I like it
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
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