Created
March 13, 2018 20:56
-
-
Save dhilst/335659b6ed740e7bd54fc791bcf24fee to your computer and use it in GitHub Desktop.
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
| const foo = new Promise((resolve,reject) => { | |
| const failed = Math.random() > 0.5; | |
| setTimeout(data => { | |
| if (failed) { | |
| reject(data); | |
| } else { | |
| resolve(data); | |
| } | |
| }) | |
| }); | |
| foo.then(x => console.log("resolved")) | |
| .catch(err => console.error("rejected")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment