BodyParser is deprecated in express App

BodyParser is Node.js parsing middleware, It makes it easier to access post data from the body of your web application.

for example you need the text from an input field in the backend of your App, body parser will easily convert it into JSON so you can use it.

Now you may be getting a message like.

'bodyParser' is deprecated

deprecated.jpg

This error message is displayed mostly if you use Express version that is above 4.16.0.

So this means if you are using Express version that is above 4.16.0. you can now parse these requests with Express.js directly, as the function of body parser has been added to Express itself.

So :

app.use(bodyParser.urlencoded({ 
extended: false 
}))

becomes :

app.use(express.urlencoded({ 
extended: false 
}))

And


app.use(bodyParser.json())

becomes :


app.use(express.json())

Thanks for reading, I'll like to know what you'll be expecting in my upcoming articles. Your feedback is warmly welcome.