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; –