Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,270 --> 00:00:00,630
All right.
2
00:00:00,630 --> 00:00:07,790
So now it's time for challenge 8. And the goals for this challenge is to update the code so that
3
00:00:07,790 --> 00: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
4
00:00:16,410 --> 00:00:23,150
then it should be at the console log what we typed in here into our console.
5
00:00:23,190 --> 00:00:31,140
So that means if we type something else say, another post, andwe click publish then we should see that immediately
6
00:00:31,500 --> 00:00:33,560
in our console.
7
00:00:33,600 --> 00:00:39,300
So this one is a little bit more challenging but there's nothing new here and you should be able to
8
00:00:39,300 --> 00:00:41,940
complete it or at least give it a really good go.
9
00:00:41,970 --> 00:00:44,930
So pause the video and complete the challenge now.
10
00:00:45,860 --> 00:00:47,490
All right here's your first hint.
11
00:00:49,350 --> 00:00:51,630
Inside our compose.ejs
12
00:00:51,780 --> 00:00:56,250
currently we've only got an input and a button.
13
00:00:56,580 --> 00:01:04,319
In order for this to actually make a post request to our server we're going to have to put it inside
14
00:01:04,470 --> 00: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
15
00:01:12,990 --> 00:01:15,200
over to our app.js.
16
00:01:15,540 --> 00:01:21,650
So pause the video and see if you can use that knowledge to complete the challenge.
17
00:01:23,400 --> 00:01:23,950
All right.
18
00:01:24,070 --> 00:01:25,390
Back for another hint?
19
00:01:25,630 --> 00:01:28,770
So let's add our form into our compose.
20
00:01:28,780 --> 00:01:34,450
ejs and I'm going to put the input and the button inside that form.
21
00:01:34,450 --> 00: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
22
00:01:40,660 --> 00:01:44,350
will submit all the content in the form.
23
00:01:44,350 --> 00: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
24
00:01:51,310 --> 00:01:53,200
the route that you're going to handle
25
00:01:53,230 --> 00:01:54,860
inside your app.js.
26
00:01:55,150 --> 00:01:58,470
So a good one might be /compose.
27
00:01:58,870 --> 00:02:07,360
So we post to the /compose route and we have an input that is of type text that needs to have
28
00:02:07,390 --> 00:02:08,870
a name
29
00:02:09,460 --> 00:02:12,820
and we have a button that submits the form.
30
00:02:12,860 --> 00:02:19,100
So now see if that was enough for you to be able to complete the challenge. OK.
31
00:02:19,110 --> 00:02:20,020
Here's a hint
32
00:02:20,030 --> 00: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
33
00:02:29,960 --> 00:02:30,740
box
34
00:02:30,740 --> 00: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
35
00:02:38,120 --> 00:02:39,690
to use a little bit later on.
36
00:02:39,710 --> 00: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
37
00:02:44,840 --> 00:02:46,110
was.
38
00:02:46,190 --> 00: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
39
00:02:53,900 --> 00:02:58,610
a post request to the /compose route.
40
00:02:58,610 --> 00:03:05,120
Now currently we don't actually address what should happen when somebody makes a post request to that
41
00:03:05,120 --> 00:03:05,750
route.
42
00:03:05,750 --> 00:03:10,190
We only address what should happen when somebody makes a get request to that route.
43
00:03:10,220 --> 00: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
44
00:03:16,580 --> 00:03:22,970
makes a post request to the /compose route. See if that was enough for you to be able to now complete
45
00:03:22,970 --> 00:03:24,110
the challenge.
4353
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.