Skip to content

Instantly share code, notes, and snippets.

@HERRKIN
Last active August 29, 2015 14:02
Show Gist options
  • Save HERRKIN/7d8170a478002945f7d3 to your computer and use it in GitHub Desktop.
Save HERRKIN/7d8170a478002945f7d3 to your computer and use it in GitHub Desktop.
var Q = require('q');
promise1(2).then(function (d) {
return promise2(d)
}).then(console.log,console.log)
function promise1 (d){
var def = Q.defer();
if(d===1){
def.resolve('resuelto promise1')
}else{
def.reject(new Error ('error in promise1'))
}
return def.promise
}
function promise2 ( d){
var def = Q.defer();
console.log(d);
def.reject(new Error ('error in promise2'))
return def.promise
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment