Skip to content

Instantly share code, notes, and snippets.

@mishelashala
Created July 24, 2020 13:10
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 mishelashala/c6d4d7272fc7de300e52cbd3aedbae00 to your computer and use it in GitHub Desktop.
Save mishelashala/c6d4d7272fc7de300e52cbd3aedbae00 to your computer and use it in GitHub Desktop.
// Promise<number>
var promisedNumber = new Promise(function asyncUnitOfWork(fulfill, reject) {
setTimeout(function () {
reject(new Error('Could not produce number'))
}, 1000)
});
console.log('start')
promisedNumber.then(
function onFulfilled(value) {
console.log('value: ', value)
},
function onRejected(err) {
console.log('error: ', err.message)
}
)
console.log('finish')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment