I make a post request to restify server 5.0.0 . but cannot get body params in req.params
with code blow:
const restify = require('restify');
const server = restify.createServer({
name: 'video-monitor-service',
version: '1.0.0'
});
server.use(restify.plugins.acceptParser(server.acceptable));
server.use(restify.plugins.queryParser());
server.use(restify.plugins.bodyParser());server.post('/scene/video/report', function(req, res, next){
console.log(req.params)
});server.listen(3600, function() {
console.log('%s listening at %s', server.name, server.url);
});
and make curl post request as blow:
curl -X POST --data "data=xxx" http://localhost:3600/scene/video/report
I Expected get
{data:xxx}
I get req.parms an empty obj
{}
something wrong with my code? and is a bug with restify 5.0.0
+1 It happens to me as well. Revert back to 4.3.1 for now.
+1 , got the same error
went back to 4.3.0
Looks like it's been deprecated...
https://github.com/restify/node-restify/blob/5.x/4TO5GUIDE.md
To re-enable, change server.use(restify.bodyParser()); to server.use(restify.plugins.bodyParser()); per this doc
They should draw more attention to this in their README.md. v5.0.0 breaks quite a few things.
It works, thank you @jgliner !
server.use(restify.plugins.queryParser({
mapParams: true
}));
server.use(restify.plugins.bodyParser({
mapParams: true
}));
It works, thank you @jgliner !
That's all it took. Thanks @jgliner!!

Change the NODE-PATH

@jgliner thanks. you save my time
Most helpful comment
It works, thank you @jgliner !