Skip to content

Instantly share code, notes, and snippets.


conanak99/promise.js Secret

Created Mar 8, 2016
What would you like to do?
// Code from:
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