I've started learning node.js
with express
framework , when I post a form like this :
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('/');
});
When I do console.log(req.body)
it displays:
[Object: null prototype] { title: 'product' }
instead of just { title: 'product' }
I'm wondering if this actually is an error with express or just a propriety that its been added to express recently , because I downloaded another project created last year and it used the same approach, when I did console.log(req.body)
, it displayed the same output.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…