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 The Request Object

Frans Teja
Frans Teja
8,175 Points

Is it a must to require body parser in your web application?

Is it a must to require body parser in your application. Is there any other way other than installing new npm to get POST request data. Thanks!

2 Answers

Bruno Navarrete
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Bruno Navarrete
Full Stack JavaScript Techdegree Graduate 22,246 Points

An HTTP response comes in an unreadable stream of data, which is a lot more difficult to work with for humans. Body-parser helps you turn it into easier-to-read and easier-to-use data. You can read a little more about it here:

What exactly does body-parser do with express.js and why do I need it?

codingchewie
codingchewie
8,764 Points

The latest version of Express 4, body-parser was integrated into it: express.urlencoded([options]) in case anyone runs across this when reading the Q&As.

To use write:

app.use(express.urlencoded({ extended: false }))
Hamdi Elshahat
Hamdi Elshahat
2,565 Points

How can I get the express version?

wildgoosestudent
wildgoosestudent
11,274 Points

This works too app.use(express.urlencoded());