如何在Express.js中访问post请求的原始正文?

如何在Express.js中访问post请求的原始正文?,express,postman,body-parser,Express,Postman,Body Parser,我和邮递员一起寄这个请求 I console.logreq.body返回如下数组: { '{"urls":["https://example.com?paramOne': 'foo', paramTwo: 'bar"]}' } 我怎样才能把整个身体变成这样一个简单的字符串呢 {"urls":["https://example.com?paramOne=foo&paramTwo=bar"]} 在app.js中: 替换: 与: 试试pm.request.body.raw app.us

我和邮递员一起寄这个请求

I console.logreq.body返回如下数组:

{ '{"urls":["https://example.com?paramOne': 'foo',
  paramTwo: 'bar"]}' }
我怎样才能把整个身体变成这样一个简单的字符串呢

{"urls":["https://example.com?paramOne=foo&paramTwo=bar"]}
在app.js中: 替换:

与:


试试pm.request.body.raw
app.use(express.json());
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: '*/*' }));