Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Express Basics Deeper into Routing with Express Statelessness, Setting and Reading Cookies

Is "cookie-parser" and "body-parser" no longer necessary?

I working with express v4.17.1

And I notice found that I can avoid need of "body-parser" with "express.urlencoded({extended:true})" and avoid "cookie-parser" with "req.cookies".

I am assuming this tutorial is slightly out-dated and that newer version of express solved this issue with native means. Do I have the right idea?

1 Answer

Henry Blandon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Henry Blandon
Full Stack JavaScript Techdegree Graduate 21,521 Points

You don't need to install body-parser, is has been deprecated. I think is integrated in express. my vs code don't event recognize it anymore. just use the code below:

app.use(express.json()) // for parsing application/json
app.use(express.urlencoded({ extended: true })) // for parsing application/x-www-form-urlencoded

The code above is from expressjs docs.

I would not say the same thing for cookie-parser.