可以參考官網說明
https://expressjs.com/en/4x/api.html#req.body
Contains key-value pairs of data submitted in the request body. By default, it is undefined, and is populated when you use body-parsing middleware such as express.json() or express.urlencoded().
預設就是 undefined
沒有錯哦,除非要特別設定 middleware
處理你需要用的參數
官網範例
let express = require('express')
let app = express()
app.use(express.json()) // for parsing application/json
app.use(express.urlencoded({ extended: true })) // for parsing application/x-www-form-urlencoded
app.post('/profile', function (req, res, next) {
console.log(req.body)
res.json(req.body)
})