-1
我有一個POST方法,調用next()
函數,但是當我嘗試訪問res
屬性時,我得到undefined
。如果我打印:req屬性爲空Express
console.log(res)
我可以看到我需要的屬性,但由於某種原因,嘗試訪問它們返回undefined
。 這是我的代碼:
app.post('/login', [function(req, res, next){
req.ID = "hello, world"
next();
}, function(req, res){
console.log(res) //I can see res.ID I am trying to access in the log
console.log(res.ID) //undefined
})
我:
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
在我的文件的最頂端。