app.use(
express.text({type: 'text/xml'}),
express.json({type: 'application/json'}),
other middlewares...) ```
Post方法标题:{连接:“保持活动”,'content-length':'1082','content-encoding':'gzip','content-type':'text / xml',接受:“ /”,'accept-encoding':'gzip',来源:“ chrome-extension:// sxwwwwagimdiliamlcqswqsw”,'accept-language':'fr-FR,fr; q = 0.9,en-US; q = 0.8,en; q = 0.7'}
Also I have tried express.raw with a wildcard for the type, but the response
is always 400.
```express.raw({type:'*/*', inflate:true}), (req, res, next)=>{console.log(req.body); next() },```
找到此nodejs教程后,我能够对其进行修复。关键是不要使用任何快速解析器,而应使用普通nodejs。
app.use(
(req, res, next)=>{
let data = []
req.on('data', chunk => {
data.push(chunk)
})
req.on('end', () => {
req.body = data.toString()
});
next()
}
)