1. Install body-parser
body-parser official website
https://www.npmjs.com/package/body-parser
Purpose:
for parsing form data
npm install body-parser
Import body-parser in app.js
// 解析表单数据的中间件
// 防止req.body等于undefined
const bodyParser = require('body-parser')
app.use(bodyParser.urlencoded({
extended: false
}))
app.use(bodyParser.json())