My Profile Photo

Rich Werden

A simple site for Rich to write about code and archive some completed projects for future reference...

#TIL: Express `bodyparser` is Already Installed! [Again]

Contrary to much of what I’ve read from even recent blog posts online [links redacted], there is no need to npm install or require body-parser into express anymore!

The powers that be have [wisely] decided to just require('body-parser') automatically in as part of the expressjs core. Basically, once upon a time, body-parser was actually part of the default modules, but then it got removed, annnnnd now minds have been _un_changed so it has been reintroduced.

Since body-parser is now built into express, in order to use it as middleware, you code it just like you would have for body-parser. So, as per (this link)[], Sept-27th, 2017, we can use what was once the body-parser syntax as follows:

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