I am assuming that get_order
function depends on the db
object and also get_user
depends on user
object. If that is the case, then you need to invoke those methods with Q.ninvoke
, like this
Q.ninvoke(db, "get_order", order_id)
.then(function(order) {
return Q.ninvoke(user, "get_user", order.user_id);
})
.then(function(user) {
console.log(user.name);
})
.catch(function(err) {
console.error(err);
});