-
-
Save wvxavier/f1d80d9f5c283f4701e34cec653cc3a1 to your computer and use it in GitHub Desktop.
promise-example
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
const doWorkPromise = new Promise((resolve, reject) =>{ | |
setTimeout(() => { | |
resolve([1,2,3]) | |
// reject('This is an error!') | |
}, 2000) | |
}) | |
doWorkPromise.then((result) => { | |
console.log('Success!', result) | |
}).catch((error) => { | |
console.log(error) | |
}) | |
// Fulfilled | |
// / | |
// Promisse --> Pending -- > | |
// \ | |
// Rejected |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment