nodeJs express 使用body-parser解析出 POST过来的 raw 格式JSON数据为空的解决方案
近日在使用express的时候,发现中间件 body-parser,无法正确解析,
无法解析的代码如下:
app.use(bodyParser.urlencoded({ extended: true }))
且无论是用 bodyParser.json() 还是 bodyParser.raw()都无法解析出来
无可奈何,自己写了个 中间函数解析 raw形式的json,代码如下:
app.use((req,res,next)=>{
let chunk = ''
req.on('data',(data
原创
2020-05-15 00:30:45 ·
2826 阅读 ·
0 评论