Loading
Current section: Mutations 7 exercises
Problem

Handling POST Requests for Form Submission

Transcript

00:00 With our form all set up, we can now start handling these POST requests. So our loader actually handles all the GET requests, and then our action handles everything else. So in particular, it handles these POST requests. So forms can only be set to GET or POST, as far as the browser is concerned.

00:18 In Remix, you can actually set the method to all of the different HTTP methods. But I don't recommend doing this because the browser is only capable of supporting POST and GET. And so if the user tries to submit your form before the JavaScript has shown up to add to that capability,

00:38 then you're gonna be in a bad situation because the user will submit the form and it will submit as a GET instead of a DELETE, which would be very problematic. So only use GET and POST. And because we have this set up as a POST, we need to add an action to handle that POST. So that's your job.

00:56 Add that action so that we can handle this POST request and then actually update the note, and we'll see what happens then.