Until now, we only created routes for GET requests. For form data, we need to work with POST requests. In this video, learn how to create a form and handle the submission in Express.js.
- [Instructor] So far we've created a dynamic website…that could display content that comes from some json file…but may also be stored in the database.…One reason to even create the dynamic website…in the first place though is that we may need…to handle user data in the one or the other way.…In our case we've got a form that allows users…to submit feedback to be displayed on the page.…We've already created the template for that…so in views, feedback, we have this index.pug file,…so in views, feedback, we have this index.pug file,…and let's review this a little bit.…
We can see that we already have a form tag in there already…but it misses two attributes.…First it needs an action.…So the action is where this form should actually be sent to.…So now add this attribute in parentheses to the form tag.…So now add this attribute in parentheses to the form tag.…For that, I simply add action equals /feedback.…Next we also need the so called method,…this is the HTTP verb that we want to use,…and this could be either get or post.…
- Creating a server with Express and pure Node.js
- Handling errors in Express
- Creating routes
- Using templates
- Working with the Pug template engine
- Implementing the site structure and logic
- Working with conditionals
- Dealing with POST requests
- Sanitizing user inputs and handling form errors
Skill Level Beginner
What you should know1m 40s
1. Getting Started
2. Express Basics
3. Getting Started with Our Project
4. Getting Started with Templates
5. Implementing the Site Structure and Logic
6. Handling Form Data
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.