Skip to content

Instantly share code, notes, and snippets.

@craigp
Last active April 16, 2018 06:52
Show Gist options
  • Save craigp/10dd66cca5dd62c1a53d to your computer and use it in GitHub Desktop.
Save craigp/10dd66cca5dd62c1a53d to your computer and use it in GitHub Desktop.
var Q = require('q');
function test2(stuff) {
return Q.promise(function(resolve, reject, notify) {
resolve("fml");
});
}
function test1(what) {
return Q.promise(function(resolve, reject, notify) {
Q(what)
.then(function(_what) {
console.log(_what);
if (_what === "what") {
console.log("resolving");
reject("fuck");
} else {
return test2(_what);
}
})
.then(function(fml) {
console.log("WHY AM I HERE?", fml);
resolve(fml);
})
.catch(function(err) {
console.log("err", err);
});
});
}
test1("what")
.then(function(result) {
console.log(result);
})
.catch(function(err) {
console.log(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment