node.js - req undefined when called from next() -
//in routes.js
test = require('test'); app.get('/test', function(req, res) { test.first( req,res, test.second, 'info' ); }); //in test.js
exports.first= function(req, res, next, inf){ req.test= inf; console.log(inf); //info next(); }; exports.second= function(req, res, next){ console.log(req); //undefined res.jsonp(req.test);//error :s }; this follow question how phone call controller express routes , include defined parameter
assuming calling next(); in test.first(), means passing no arguments test.second(). current setup need next(req, res); in test.first() instead.
node.js express routing undefined
No comments:
Post a Comment