I was working on a simple API using Node.JS and Restify tonight and had everything fine in terms of receiving parameters via req.params.fieldname
. I installed CouchDB and Cradle in order to start trying to throw those parameters into a database, but after getting everything installed req.params started to come back empty!
I should have been using Express to begin with for other reasons, so I tried switching to that to see if I could get it working but no such luck.
var express = require('express');
var app = express.createServer();
app.configure(function(){
app.use(express.bodyParser());
app.use(express.cookieParser());
});
app.post('/', function(req, res){
res.send(req.body);
});
app.listen(8080, function() {
console.log('Printomatic listening at', app.url);
});
I've tried countless variations but no matter what req.body comes back empty. I'm using http-console to test, and sending things as simple as POST /
with content {"name":"foobar"}
I'm so frustrated that at this point I'm beginning to wonder if I broke something when installing Cradle/CouchDB (which were installed with NPM and Homebrew, respectively). Any help would be greatly appreciated as this is somewhat time-sensitive. Thanks for any help in advance!