WEBVTT 0 00:00.270 --> 00:00.630 All right. 1 00:00.630 --> 00:07.790 So now it's time for challenge 8. And the goals for this challenge is to update the code so that 2 00:07.790 --> 00:15.780 when we go over to our compose page and we type something, let's say, Day one right? And we click publish 3 00:16.410 --> 00:23.150 then it should be at the console log what we typed in here into our console. 4 00:23.190 --> 00:31.140 So that means if we type something else say, another post, andwe click publish then we should see that immediately 5 00:31.500 --> 00:33.560 in our console. 6 00:33.600 --> 00:39.300 So this one is a little bit more challenging but there's nothing new here and you should be able to 7 00:39.300 --> 00:41.940 complete it or at least give it a really good go. 8 00:41.970 --> 00:44.930 So pause the video and complete the challenge now. 9 00:45.860 --> 00:47.490 All right here's your first hint. 10 00:49.350 --> 00:51.630 Inside our compose.ejs 11 00:51.780 --> 00:56.250 currently we've only got an input and a button. 12 00:56.580 --> 01:04.320 In order for this to actually make a post request to our server we're going to have to put it inside 13 01:04.470 --> 01:12.600 a form so that when we submit the form we can pass over the value that the user typed into this input 14 01:12.990 --> 01:15.200 over to our app.js. 15 01:15.540 --> 01:21.650 So pause the video and see if you can use that knowledge to complete the challenge. 16 01:23.400 --> 01:23.950 All right. 17 01:24.070 --> 01:25.390 Back for another hint? 18 01:25.630 --> 01:28.770 So let's add our form into our compose. 19 01:28.780 --> 01:34.450 ejs and I'm going to put the input and the button inside that form. 20 01:34.450 --> 01:40.660 Now you need to make sure that the button is of type submit so that when you actually click on it it 21 01:40.660 --> 01:44.350 will submit all the content in the form. 22 01:44.350 --> 01:51.310 Now the other thing you have to check is that your form has a method of post and that the action is 23 01:51.310 --> 01:53.200 the route that you're going to handle 24 01:53.230 --> 01:54.860 inside your app.js. 25 01:55.150 --> 01:58.470 So a good one might be /compose. 26 01:58.870 --> 02:07.360 So we post to the /compose route and we have an input that is of type text that needs to have 27 02:07.390 --> 02:08.870 a name 28 02:09.460 --> 02:12.820 and we have a button that submits the form. 29 02:12.860 --> 02:19.100 So now see if that was enough for you to be able to complete the challenge. OK. 30 02:19.110 --> 02:20.020 Here's a hint 31 02:20.030 --> 02:29.960 3. In order for us to be able to tap into the value of the input that the user puts into this text 32 02:29.960 --> 02:30.740 box 33 02:30.740 --> 02:38.120 we have to give it a name. So let's call it something like post title because this is what we're going 34 02:38.120 --> 02:39.690 to use a little bit later on. 35 02:39.710 --> 02:44.840 Now it doesn't matter if you call it something else as long as you remember what the name for this input 36 02:44.840 --> 02:46.110 was. 37 02:46.190 --> 02:53.900 Now once we submit this form then it's going to go over to our app.js and it's going to try and make 38 02:53.900 --> 02:58.610 a post request to the /compose route. 39 02:58.610 --> 03:05.120 Now currently we don't actually address what should happen when somebody makes a post request to that 40 03:05.120 --> 03:05.750 route. 41 03:05.750 --> 03:10.190 We only address what should happen when somebody makes a get request to that route. 42 03:10.220 --> 03:16.580 So you're going to need to add a post method inside here to tell the server what it should do when somebody 43 03:16.580 --> 03:22.970 makes a post request to the /compose route. See if that was enough for you to be able to now complete 44 03:22.970 --> 03:24.110 the challenge.