0
if (token_count == 1) {
var user_name = rows[0].user_name;
next();
} else {
data = {
message :"Invalid Token"
}
res.send(data);
}
我需要通过USER_NAME从参数的next(),它被调用的函数为波纹管,传递参数的NodeJS
router.post('/dashboard', function (req, res) {
// user_name must be fetched here
console.log("middleware next")
});
我已经通过使用res.locals解决了它 res.locals.user_name = user_name; –