Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
- POST Requests 6:26
- The Request Object 4:29
- Review: The Request Object 5 questions
- The Response Object 5:29
- Review: The Response Object 5 questions
- Review Adding Multiple Routes 2 objectives
- Statelessness, Setting and Reading Cookies 9:41
- Review: Statelessness 5 questions
- Redirects 5:44
- Challenges: Redirects 2:37
- Solution: Clearing Cookies and Redirecting 1:55
- Review: Redirects 5 questions

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
A closer look at Express's Request object.
A note on body-parser
If you are following along with the same version of Express installed in this course (v4.15.2), you should have no problems with using body-parser here. However, if you are using a more recent version of Express (v4.16.0 or higher) you will only need to use the following at the beginning of your document: app.use(express.urlencoded());
.
You can read more about this newer built-in middleware in the Express Documentation
HTML Forms
-
Sending form data (MDN)
- HTML forms (MDN general form page)
Documentation
What body-parser
Does Under the Hood
What is body-parser doing? In case you're curious, here's a little code that reads the body of an incoming request and logs it to the console. This is just a flavor of how using body-parser is making your life easier!
let bodyString = ''
req.on('data', chunk => bodyString += chunk.toString());
req.on('end', () => {
console.log(bodyString);
});
Note that even after bodyString
has been read completely, it still needs to be turned from a string into data your application can use, all of which is taken care of by body-parser.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
Hamzah Iqbal
Full Stack JavaScript Techdegree Student 11,145 Points1 Answer
-
marcell gibbs
3,744 PointsFYI
Posted by marcell gibbsmarcell gibbs
3,744 Points2 Answers
-
Michael Cook
Full Stack JavaScript Techdegree Graduate 28,975 Points7 Answers
-
Katie Shook
12,326 Points2 Answers
-
Lana Toogood
10,158 Points1 Answer
-
vamosrope14
14,932 Points1 Answer
-
Adam Lyles Kauffman
14,016 Points1 Answer
-
Vlad Tanasie
7,201 PointsWhat is the theme and plugin for the text color that is used by the teacher in this video with VSCode.
Posted by Vlad TanasieVlad Tanasie
7,201 Points1 Answer
-
Daniel Hernandez
13,437 Points1 Answer
-
Akhil Nair
4,150 PointsI did console.dir(req) on my machine, but the output for req object doesn't show up in the browser console.
Posted by Akhil NairAkhil Nair
4,150 Points1 Answer
-
Frans Teja
8,175 PointsIs it a must to require body parser in your web application?
Posted by Frans TejaFrans Teja
8,175 Points2 Answers
-
bnywa
1,266 Points0 Answers
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up