我有以下函数写在server.js我一直得到 error: uncaughtException: Cannot call method 'redirect' of undefined
function(req, res) {
async.waterfall([
function(next){
next(null, res);
},
function(next){
next(null, res);
},
function(next, res){
res.redirect('www.google.com')
}
]);
}
Run Code Online (Sandbox Code Playgroud)
从以下答案进行上述更改后我得到了,错误如下:
2014-09-04T13:56:08.678Z - error: uncaughtException: Object function (err) {
if (err) {
callback.apply(null, arguments);
callback = function () {};
}
else {
var args = Array.prototype.slice.call(arguments, 1);
var next = iterator.next();
if (next) {
args.push(wrapIterator(next));
}
else {
args.push(callback);
}
async.nextTick(function () {
iterator.apply(null, args);
});
}
} has no method 'send'
Run Code Online (Sandbox Code Playgroud)
小智 5
为什么需要将res作为瀑布参数传递?您可以在全局功能范围内使用它,就像这样
function(req, res) {
async.waterfall([
function(next){
next();
},
function(next){
next();
},
function(){
res.redirect('www.google.com')
}
]);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1752 次 |
| 最近记录: |