1.Express默认只支持json
与x-www-form-urlencoded
格式的数据.
2.前端代码中要注意请求头!
3.nodejs代码,在入口文件index.js中需要用到中间件去处理,然后挂载到app上
用express本身的也行:app.use(express.json())
或者中间件body-parser, yarn add body-parser --save
app.use(bodyParser.json()) / app.use(bodyParse.urlencoded({extended:true,limit:'100mb'}))
4. 然后最重要的是app.use(express.json()) / app.use(bodyParser.json()) / app.use(bodyParse.urlencoded({extended:true,limit:'100mb'})) 这段代码的顺序要在引入的路由文件前面,这是最重要的!