I have following function written in server.js I keep getting 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')
}
]);
}
After making above changes from the answer below I'm getting, error as follows:
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'
Why do you need to pass res as waterfall parametr ? Why you can't use it from global scope of function, simply like this
function(req, res) {
async.waterfall([
function(next){
next();
},
function(next){
next();
},
function(){
res.redirect('www.google.com')
}
]);
}