【发布时间】:2014-03-20 12:35:41
【问题描述】:
我正在使用 Q 作为我的异步模块来开发 nodejs。以下调用了第一个函数,但之后没有任何内容,并且应用程序没有返回任何内容 - 它只是一直在等待。
return Q.ninvoke(exports, 'parseUser', req, null)
.then(function(user) { console.log(1) })
.then(exports, 'postCreateUser', user)
.then(function() { console.log(2); })
.then(req, 'login', user)
.then(function() { console.log(3); })
.then(function(user) { return res.redirect('/go'); })
.then(function() { console.log(4); })
.catch(function (err) { return exports.createValidationError(err, req, res, user); });
我做错了什么?
【问题讨论】:
-
您需要将函数传递给
then()。试试.then(exports.postCreateUser(exports, user))左右。
标签: javascript node.js asynchronous promise q