我已经开始学习express
框架下的node.js
,当我发布这样的表格时:
router.get('/add-product',(req,res,next)=>{
res.send('<form action="/product" method="POST" ><input type="text" name="title" /><button type="submit">Submit</button></form>');
});
router.post('/product',(req,res,next)=>{
console.log(req.body);
res.redirect('/');
});
当我做console.log(req.body)
次时,它会显示:
[Object: null prototype] { title: 'product' }
而不是仅仅{ title: 'product' }
我想知道这究竟是express的一个错误,还是它最近被添加到express中的一个恰当的做法,因为我下载了go 年创建的另一个项目,它使用了相同的方法,当我完成console.log(req.body)
次时,它显示了相同的输出.