Express.js req.body undefined

前端 未结 30 2756
半阙折子戏
半阙折子戏 2020-11-22 12:02

I have this as configuration of my Express server

app.use(app.router); 
app.use(express.cookieParser());
app.use(express.session({ secret: \"keyboard cat\" }         


        
30条回答
  •  情深已故
    2020-11-22 12:44

    You can try adding this line of code at the top, (after your require statements):

    app.use(bodyParser.urlencoded({extended: true}));
    

    As for the reasons as to why it works, check out the docs: https://www.npmjs.com/package/body-parser#bodyparserurlencodedoptions

提交回复
热议问题