Skip to main content

Command Palette

Search for a command to run...

BodyParser is deprecated in express App

Updated
1 min read
A

I’m a Software Developer passionate about writing on software development.

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.

R
ROXED LTD4y ago

Thank you sir, but in the last content you're wrong. After I check becomes :

app.use(express.json())
1
A

Thanks for the observation, necessary changes have been made.

A

But I am not able to get data in form data with postman I am using express 4.17.1 wit node js .Abdulfatai Mukhtar

More from this blog

Backend Developer

32 posts