nodejs in req.body empty question

With the express upgrade, bodyParser from express is separated out, therefore, when using the new version express the need npm install body-parser to install bodyParser.

  1. In app.js to be introduced bodyParser.

    var bodyParser = require(‘body-parser‘);

  2. Secondly, we need to use bodyParser in app.js in.

    app.use(bodyParser());

  3. Finally, the need to provide parameters to bodyParser.

    ‘Content-Type‘: ‘application/x-www-form-urlencoded‘ 

    For the parameter bodyParser according to parse the file type to be provided, there are many types of parameters, can view the specific document.

Guess you like

Origin www.cnblogs.com/ydam/p/10983541.html