添加了urlencoded之后,出现以下错误,多了前面的[Object: null prototype]
作者:互联网
问题:
解决方案:
plan A:extended传为true, true/false代表使用解析的library不一样: qs/querystringapp.use(bodyParser.urlencoded({extended: true}))
plan B: 采用规避手段
if (req.body.__proto__ === undefined) { Object.setPrototypeOf(req.body, new Object()); }
plan C: 设置ajax的Content-Type: application/json; charset=utf-8, 同时需要设置app.use(bodyParser.json())
标签:use,req,app,Object,urlencoded,prototype,true,plan 来源: https://blog.csdn.net/adam_De/article/details/120654182