npmnode.js95% confidence\u2191 577

Express.js req.body undefined

Full error message
I have this as configuration of my Express server

app.use(app.router); 
app.use(express.cookieParser());
app.use(express.session({ secret: "keyboard cat" }));
app.set('view engine', 'ejs');
app.set("view options", { layout: true });
//Handles post requests
app.use(express.bodyParser());
//Handles put requests
app.use(express.methodOverride());

But still when I ask for req.body.something in my routes I get some error pointing out that body is undefined. Here is an example of a route that uses req.body :

app.post('/admin', function(req, res){
    console.log(req.body.name);
});

I read that this problem is caused by the lack of app.use(express.bodyParser()); but as you can see I call it before the routes.

Any clue?

As already posted under one comment, I solved it using app.use(require('connect').bodyParser()); instead of app.use(express.bodyParser()); I still don't know why the simple express.bodyParser() is not working...

API access

Get this solution programmatically \u2014 free, no authentication.

curl https://depscope.dev/api/error/9115c85cb2ccce60ef6b4d852e636f81959d1a3029ef8be2967ce13f74f4905a
hash \u00b7 9115c85cb2ccce60ef6b4d852e636f81959d1a3029ef8be2967ce13f74f4905a
Express.js req.body undefined — DepScope fix | DepScope