Current section: Forms 59 exercises
Problem

Form Action

Loading exercise

Transcript

00:00 So, you know how we're doing a full-page refresh? Well, the reason that is happening is because we are making a server request. We need to send the data that the user enters into this form over to the server.

00:13 And the default behavior for that is to make a request at the current URL. And so, that is why if I put my username as Kent C. Dodds and hit submit, then we're going to get this question mark username. So, we serialize the values of the form into the URL, trigger full-page refresh, and now

00:31 the server knows what those submitted values are based on what the URL looks like. So, you can control where that ends up going, like what route on your server that ends up

00:47 going to with the action proper attribute in HTML, the action attribute on that form. And so, you can say, I want it to go to this URL, whatever. So, your task in this exercise is to change that because we have a little mini-backend, this API.server.

01:07 The workshop app is going to serve this for us, and it already has a loader. This is to handle the get request that is being made. The workshop app will take care of taking that request that comes in and then passing it on to your loader here. And so, here we are grabbing the search params, and then we're going to respond with a data

01:26 table. This backend stuff is out of scope for this workshop. That's why it's already done for you. But I think it is important for you to understand how to set this action and how that all flows together. So, that is your job in this exercise. Add an action and see what happens when you submit. It should be pretty quick. See you when you're done.