关于nodejs里面使用express框架中的req.body 获取post传值为undifined问题
今天在使用express框架获取post表单的值时老是报undifined,加上这三行代码就可以了
let bodyParser = require(‘body-parser’)
通过 npm install body-parser --save 或(cnpm install body-parser --save)安装
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
注意第二三行代码要放在
let app = express();下面,否则会报错