[英]Can't get request body with resify using Postman to send data
我正在使用Restify服务器(节点版本为v9.11.1,restify版本为6.4.0)。
这是我的服务器配置:
server.use(restify.plugins.queryParser({ mapParams: true }))
server.use(restify.plugins.bodyParser({ mapParams: true }));
server.pre(restify.plugins.pre.userAgentConnection());
server.use(restify.plugins.acceptParser(server.acceptable));
server.pre(cors.preflight);
server.use(cors.actual);
现在,我想使用Postman进行代码示例测试。 我想测试查询参数和身体参数:
server.post('/ping/:param1', (req, res, next ) => {
console.log(req.params);
console.log(req.body);
res.send(200, { "ping" :true} );
return next() ;
});
我的邮递员配置:
POST查询后,我可以获取查询参数,但是无法获取主体数据:
{ param1: 'value1' }
undefined
我刚刚使用上面列出的服务器设置创建了一个简单的restify服务器,除了省略了cors之类的东西。 然后,我使用curl击中服务器:
curl -F "hello=world" localhost:5555/ping/goodbye
我在服务器标准输出上得到了这个:
{ param1: 'goodbye', hello: 'world' }
{ hello: 'world' }
我不使用Postman,所以我无法确定它是否可能无法正常工作,但是使用curl可以正常工作。
我的版本信息如下。
process.versions {http_parser:'2.7.0',节点:'8.2.1',v8:'5.8.283.41',uv:'1.13.1',zlib:'1.2.11',ares:'1.10.1 -DEV”,模块:“ 57”,openssl:“ 1.0.2l”,icu:“ 59.1”,unicode:“ 9.0”,cldr:“ 31.0.1”,tz:“ 2017b”}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.