express獲取數據的方法
一.get請求(獲取url上面的參數)
req.query
二.post請求(獲取請求體裏面的參數)
1.先安裝body-parser
npm install body-parser --save-dev
2.使用
const bodyParser = require('body-parser')
app.use(bodyParser.urlencoded({
extended: false
}))
app.use(bodyParser.json())
//這樣就可以直接使用req.body獲取參數了