I'm trying to make a server which stores Json posts, here is the server so far:
var restify = require('restify');
var server = restify.createServer();
server.post('/message/', function create(req, res, next) {
console.log(req.params)
return next();
});
server.listen(8080, function() {
console.log('%s listening at %s', server.name, server.url);
});
I'm using the Restify client to make the posts
var restify = require('restify');
var client = restify.createJsonClient({
url: 'http://localhost:8080',
version: '*'
});
client.post('/message/', { hello: 'world' }, function(err, req, res, obj) {
console.log('%d -> %j', res.statusCode, res.headers);
console.log('%j', obj);
});
The problem is that req.params is empty. What's missing?
Before server.post
do server.use(restify.bodyParser());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With