body parser package is deprecated. If you are using latest version of express you don't have to install body-parser package.
You can directly use
app.use(express.urlencoded({extended:true});
If you facing 'bodyParser' is deprecated.
Just do
app.use(express.urlencoded({extended: true}));
app.use(express.json());
Note: If you are using 4.16.0 or later express version.
Body parser is now added to Express. You can use it like the following:
app.use(express.json());
You can add this middleware to the code which will then be able to use json methods.
Body parsing is now builtin with express So, simply do
app.use(express.json()) //For JSON requests
app.use(express.urlencoded({extended: true}));
directly from express
You can uninstall body-parser using npm uninstall body-parser
Then you can get the POST content of the request using req.body
app.post("/yourpath", (req, res)=>{
var postData = req.body;
//Or like this, for string JSON body
var postData = JSON.parse(req.body);
});