I am having trouble reading parameters from the request body for a post request i know this has been asked several times but all the answer are saying to call the body parser before calling app.use() for the routes i did this and also called bodyparser.urlencode() and and it's still giving me undefined whenever i console.log(req.body) or just prints {} ( an empty object)
this is my code
const bodyParser=require('body-parser');
const express=require('express');
const app=express();
app.use(
bodyParser.urlencoded({
extended: false
})
)
app.use(bodyParser.json())
app.post('/endpoint', (req, res) => {
console.log(req.body);
res.status(400).send({ "ReturnMsg": "User Already Exits" });
})
// the port where the application run
const port = process.env.PORT || 6001;
app.listen(port, () => console.log(`Listening on port ${port}...`));