WEBVTT 00:01.560 --> 00:05.880 So we have the form displaying properly and of course, now we need to populate it with information 00:05.880 --> 00:08.430 for an existing user and that's pretty straightforward. 00:09.360 --> 00:14.910 So let's go over to Route's Dash API, which is what we'll be calling using fetch from our front end 00:14.940 --> 00:18.090 and here in the protected section, right after all, users. 00:18.110 --> 00:21.810 I'll add a route to a non-existent handler which will create in the moment. 00:22.330 --> 00:31.380 I'll make it a post route and it will be to add apps and all dash users and then some ID and we'll grab 00:31.380 --> 00:37.790 the ID as necessary, of course, and then we'll go to app, say, one user, which doesn't exist. 00:37.800 --> 00:43.500 So let's go create that over in handler dash API right here at the bottom. 00:44.910 --> 00:45.770 We'll create a function. 00:45.780 --> 00:53.400 I'll just copy this one to save some time and paste it in there and make this one user. 00:54.630 --> 01:02.090 And of course, we need to grab the I.D. from you URL, so as is a sign the value of you are program 01:02.430 --> 01:05.220 and we're going to hand it our. 01:06.280 --> 01:12.070 Which is our request and we're looking for it, and we'll convert that to an INT, which I need it to 01:12.070 --> 01:20.860 be in user ID, not ignore the error and you shouldn't is assign the value of Sterkel to I and we're 01:20.860 --> 01:21.940 going to convert it. 01:22.990 --> 01:27.150 And once I have that, I'm going to call, not get all users. 01:27.160 --> 01:35.470 Instead I'll call that and get one user and handed the ID user ID and will remain this variable to say 01:35.470 --> 01:38.050 user and we'll handle the user. 01:39.610 --> 01:44.560 So that should work for the backend, that should get the ID, go to the database, grab the user ID, 01:44.560 --> 01:47.050 convert it to Jason and write it to the end user. 01:48.250 --> 01:51.520 Now back here on one user page Dutko HTML of course. 01:52.720 --> 01:58.390 We need to call that, and that's as simple as adding in some script tags 02:01.540 --> 02:03.910 and putting in a document at event listener. 02:10.280 --> 02:13.190 And our condition is dom content loaded 02:16.790 --> 02:17.990 and we'll execute this function. 02:21.230 --> 02:27.140 Now the first thing we're going to do, of course, is get our token, let token equal local storage 02:30.020 --> 02:30.700 yet item. 02:31.340 --> 02:32.300 And we're looking for token. 02:34.280 --> 02:37.810 And we also need to get the ID from the URL and we've already done that. 02:37.830 --> 02:44.750 It's as simple as it is equal to or let into equal window, location, 02:47.750 --> 02:50.840 path, name, dot split. 02:53.210 --> 02:59.720 And we're splitting on the slash and we pop and that gives us even the URL. 03:03.810 --> 03:05.610 Now we create some request options 03:12.750 --> 03:20.030 and we're going to have a method post, which is what we set our route to and our headers and the sender 03:20.040 --> 03:20.340 would 03:25.740 --> 03:26.310 accept 03:28.950 --> 03:30.900 an application duration 03:33.840 --> 03:34.710 content type. 03:39.180 --> 03:45.930 Also, application, Jason, Jason, and authorization. 03:53.170 --> 03:57.820 Which would be better space and our token. 04:01.150 --> 04:09.400 Now we just call, fetch, fetch, and we're going to fetch to the API route, which is hand hand it 04:09.400 --> 04:19.930 to every templated in our system, apress it, all the users slash and then append ID to it and handed 04:19.930 --> 04:23.530 the request options and I better close that properly. 04:25.750 --> 04:28.360 Plus I request options. 04:30.310 --> 04:36.010 Then we convert our response to Jason. 04:44.470 --> 04:47.260 Then and for right now, we'll just say function data. 04:52.250 --> 05:00.860 Let's just write things to the console to make sure it works, console dialogue, you know, OK, let's 05:00.860 --> 05:03.320 start everything, Mr.. 05:07.640 --> 05:12.950 Go back to your Web browser, open our console login 05:16.160 --> 05:17.930 that mean at example dot com 05:22.040 --> 05:30.590 password and once login and go to admin all users and click on user. 05:32.530 --> 05:38.860 And over here, I get an object with an idea of one first name and last name user, there's the email 05:38.860 --> 05:42.670 and the password is set to empty, as it should be, since we never populated it. 05:43.450 --> 05:45.190 OK, so the next step is simple. 05:45.190 --> 05:50.710 We simply grab the information from our Jason and populate this form, and we'll take care of that in 05:50.710 --> 05:51.430 the next lecture.