{"id":481,"hash":"9115c85cb2ccce60ef6b4d852e636f81959d1a3029ef8be2967ce13f74f4905a","pattern":"Express.js req.body undefined","full_message":"I have this as configuration of my Express server\n\napp.use(app.router); \napp.use(express.cookieParser());\napp.use(express.session({ secret: \"keyboard cat\" }));\napp.set('view engine', 'ejs');\napp.set(\"view options\", { layout: true });\n//Handles post requests\napp.use(express.bodyParser());\n//Handles put requests\napp.use(express.methodOverride());\n\nBut 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 :\n\napp.post('/admin', function(req, res){\n    console.log(req.body.name);\n});\n\nI 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.\n\nAny clue?","ecosystem":"npm","package_name":"node.js","package_version":null,"solution":"As already posted under one comment, I solved it using \n\napp.use(require('connect').bodyParser());\n\ninstead of \n\napp.use(express.bodyParser());\n\nI still don't know why the simple express.bodyParser() is not working...","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/9177049/express-js-req-body-undefined","votes":577,"created_at":"2026-04-19T04:51:14.642806+00:00","updated_at":"2026-04-19T04:51:14.642806+00:00"}