查看package.json中是下载过body-parser
如果没有则通过npm下载body-parser
var bodyParser = require('body-parser'); var app = express(); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); //以下为路由配置 var routes = require('./routes/index'); var users = require('./routes/users'); ...other code...
来源:node.js提示req.body为undefined_使用mockjs时post请求的body属性显示为undefined-CSDN博客
标签:body,parser,undefined,app,req,var From: https://www.cnblogs.com/brillant/p/17757956.html