我发邮件给你这个请求。
我console.log(req.body)
返回一个这样的数组:
{ '{"urls":["https://example.com?paramOne': 'foo',
paramTwo: 'bar"]}' }
如何将整个身体变成这样的简单字符串?
{"urls":["https://example.com?paramOne=foo¶mTwo=bar"]}
答案 0 :(得分:1)
In app.js
:
Replace:
app.use(express.json());
With:
var rawBodySaver = function (req, res, buf, encoding) {
if (buf && buf.length) {
req.rawBody = buf.toString(encoding || 'utf8');
}
}
app.use(bodyParser.json({ verify: rawBodySaver }));
app.use(bodyParser.urlencoded({ verify: rawBodySaver, extended: true }));
app.use(bodyParser.raw({ verify: rawBodySaver, type: '*/*' }));