Created
April 27, 2017 18:24
-
-
Save Ibro/abcae31e7eab39e5377850a7679e518a to your computer and use it in GitHub Desktop.
Promise JavaScript - Coding Blast - www.codingblast.com
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
function iGiveYouAPromise(value: number) { | |
return new Promise(function (resolve, reject) { | |
if (value === 4141) { | |
reject('Number is too weird..') | |
} else { | |
setTimeout(function () { | |
resolve('Success!'); | |
}, 1500); | |
} | |
}); | |
} | |
let promise = iGiveYouAPromise(151); | |
promise.then(function (resp) { | |
console.log('inside of success callback! value:', resp); | |
}, function (err) { | |
console.log('inside of error callback! error:', err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment