如何在 post 方法中获取令牌或 req.query.id?
router.route('/reset')
.get(isNotAuthenticated, (req, res) => {
token = req.query.id;
console.log(token);
res.render('reset');
})
.post(async (req, res, next) => {
try {
console.log(token);
}
})
通常我们在 POST 方法中通过body传输数据。
并通过以下方式访问数据:req.body
但是对于令牌,我相信它是通过标头发送的。
若要获取标头数据,请使用req.headers