Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Body Parser Deprecated

I am currently learning node and express. But when I require and use body-parser my code editor(VS Code) says that it is deprecated. How do I work with this? I will link the image of my editor.enter image description here

like image 360
Arun Bohra Avatar asked Mar 09 '21 13:03

Arun Bohra


People also ask

Is body parser deprecated?

'bodyParser' is deprecated. // If you are using Express 4.16+ you don't have to import body-parser anymore.

Is body parser deprecated 2021?

body parser package is deprecated. If you are using latest version of express you don't have to install body-parser package.

Do you still need body parser?

No need to install body-parser with express , but you have to use it if you will receive post request.


2 Answers

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.

like image 138
Happy Patel Avatar answered Sep 20 '22 11:09

Happy Patel


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});
like image 30
narendra Avatar answered Sep 20 '22 11:09

narendra