1. 安装
npm install body-parser
2.
var bodyParser = require(‘body-parser‘); //只要加入这个配置,在req请求对象上会多出来一个属性 //parse application/x-www-form-urlencoded app.use(bodyParser.urlencoded({ extended: false })) //parse application/json app.use(bodyParser.json())
app.post(‘/test‘, function(req, res) {
console.log(req.body);
});
原文地址:https://www.cnblogs.com/flyerya/p/11433073.html
时间: 2024-10-11 06:07:07