-
-
Save conanak99/d1f70f6a495d6d473817 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
// Code from: http://www.html5rocks.com/en/tutorials/es6/promises/ | |
var promise = new Promise(function(resolve, reject) { | |
// do a thing, possibly async, then… | |
if (true) { | |
resolve("Stuff worked!"); | |
} | |
else { | |
reject(Error("It broke")); | |
} | |
}); | |
promise.then(function(result) { | |
console.log(result); // "Stuff worked!" | |
}, function(err) { | |
console.log(err); // Error: "It broke" | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment