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 trialFrans Teja
8,175 PointsIs 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
Full Stack JavaScript Techdegree Graduate 22,246 PointsAn 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
8,764 PointsThe 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
2,565 PointsHow can I get the express version?
wildgoosestudent
11,274 PointsThis works too app.use(express.urlencoded());