Question App in Nodejs, Pug, Body-Parser Parsing Form Data 4

Channel:
Subscribers:
8,020
Published on ● Video Link: https://www.youtube.com/watch?v=dzM5KNYfrxA



Duration: 7:04
289 views
3


Our question app in Nodejs is coming along nicely. Slowly but surely we will make it happen. In today’s lesson we look at reading form data. The first thing we do is create a GET route (‘/hello’) which renders a new file we create called ‘hello.pug’. Our ‘hello.pug’ file welcomes a user only if he has entered his name? We do this using an if statement. We say if name exists welcome user with “Hello #{name}” We have an else right after which will run if no name exists which displays a form which asks user to enter their name. In order to read in their name entered in the form we learn that we need to parse their form data. We ‘npm install body-parser’ which parses form data and sends it in the request. We access the value which will be in the ‘body’ of the request. In our route we target our form data, which we gave the name ‘username’ to, by using ‘req.body.username’. This lesson is vital in your journey towards backend development, for it allows you to parse valuable form data. Next we will learn how to save our sessions using cookies.




Other Videos By We Will Code


2018-08-31freeCodeCamp's Create Visual Balance Using The Text-align Property, Applied Visual Design
2018-08-30freeCodeCamp's Intro to the Applied Visual Design Challenges
2018-08-21freeCodeCamp Basic CSS, Use Hex and RGB to Mix Colors, CSS Variables, & Style Fallbacks 6
2018-08-14freeCodeCamp Basic CSS,Clockwise Notation for Padding & Margin, CSS Precedence Specificity 5
2018-08-07freeCodeCamp Basic CSS, Size Images, Setting Id's, Margins, Paddings, & Borders 4
2018-08-02freeCodeCamp Basic CSS, Change Element Colors,Class Selector, Font Degradation 3
2018-07-20freeCodeCamp Basic HTML5 Nest an Anchor - Head and Body of HTML Doc 2
2018-07-18freeCodeCamp Basic HTML Tutorial Say Hello - Link to Internal Sections w Anchor Elements 1
2018-07-12Question App in Nodejs, Pug,Redirects and Cookie Practice
2018-07-09Question App in Nodejs, Pug,cookie-parser, setting cookies 5
2018-06-29Question App in Nodejs, Pug, Body-Parser Parsing Form Data 4
2018-06-27Question App in Nodejs, Pug, Express, Include Partials 3
2018-06-26Question App in Nodejs, Pug, Express, Rendering Response 2
2018-06-25Question App in Nodejs, Express, Flash Card App with Pug Templating
2018-06-22Codecademy's Learn Express, Matching Longer Paths, ExpressJS
2018-06-21Codecademy's Learn Express, Setting Status Codes
2018-06-19Codecademy's Learn Express, Getting a Single Expression
2018-06-18Codecademy's Learn Express, Matching Route Paths, Understanding Express JS
2018-06-15Codecademy's Learn Express, Sending a Response, Nodejs Backend
2018-06-14Codecademy's Learn Express, Writing Your First Route
2018-06-13Codecademy's Learn Express, Starting a Server, Back-End Apps



Tags:
Express tutorial
learning express
express js
express routes
bodyparser
body-parser
req.body