Created
January 31, 2020 22:41
-
-
Save secretgspot/683d2c69a1b73bc4a3410b1545044822 to your computer and use it in GitHub Desktop.
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
let arrived = true; | |
// Create a Promise | |
const ride = new Promise((resolve, reject) => { | |
if (arrived) { | |
resolve('driver arrived'); | |
} else { | |
reject({msg: 'rejected', code: 222}); | |
} | |
}); | |
// Consume a Promise | |
ride | |
.then(value => { | |
console.log('val: ', value); | |
}) | |
.catch(err => { | |
console.log('err: ', err); | |
}) | |
.finally(() => { | |
console.log('do cleanup') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment