I am using a Restify server (node version is v9.11.1, restify version is 6.4.0).
Here is my server config :
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);
Now, I want to test with a code sample, using Postman. I want to test query params and body params :
server.post('/ping/:param1', (req, res, next ) => {
console.log(req.params);
console.log(req.body);
res.send(200, { "ping" :true} );
return next() ;
});
My Postman configurations:
- Content-Type as application/json
- POST on url : http://127.0.0.1:8080/ping/value1 ( in order to test query parameters)
- Body as "Raw" with content : { "hello" : "world" } ( to test body data)
After a POST query, I can get the query parameters, but I cant get the body data :
{ param1: 'value1' }
undefined