'express.js req.body undefined in middleware
I'm currently facing a problem in my node application.
while trying to use middleware in a post request the req.body becomes undefined.
for example;
router.post('/newpost', ensureAuthenticated, createPost, upload.single('file'), async (req, res) =>{
console.log(req.body);
}
async function createPost(req, res, next){
console.log(req.body);
next();
}
when the createPost function runs it logs req.body as undefined. but when req.body gets logged inside the router.post it is defined.
is it something i'm missing? or is this just not possible to do.
also i've ensured that i've included bodyparser and initialized it before my routes.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
