如何使用body-parser解析post方法传递的参数
2020-03-04 本文已影响0人
回不去的那些时光
可以通过 body-parser 这个中间件来解决这个问题
npm i -S body-parser
在 app.js 中加入
const bodyParser = require('body-parser')
// 创建 express 应用
const app = express()
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())