From the course: Building a Website with Node.js and Express.js

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Handling POST requests

Handling POST requests

- [Instructor] So far, we've created a dynamic website that could display content that comes from some JSON file, but may be also stored in the database. One reason to even create a 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 a template for that and let's look at this real quick. So I'm opening Visual Studio Code and I'll open Feedback.ajs. We can see that there is a form in there already, but it misses a few things. First of all, I hope you know HTML. It needs a method, so I add now the form method and I want to send this form via POST request, which is very common for any type of form. Then I also need an action, so that's the URL the form data needs to be sent to, and I want to send it to /feedback, so that's the post route we created…

Contents