express version
5.x
post body
- The 5.x version does not need to install the body-parser middleware, and the body can be used with a simple configuration ↓
code
import express from 'express'
const app = express()
// 配置post的body
app.use(express.json())
app.use(express.urlencoded({
extended: true }))
app.post('/test1', (req, res, next) => {
console.log(req.body)
res.json(req.body)
})