All right. 1
So now it's time for challenge 8. And the goals for this challenge is to update the code so that 2
when we go over to our compose page and we type something, let's say, Day one right? And we click publish 3
then it should be at the console log what we typed in here into our console. 4
So that means if we type something else say, another post, andwe click publish then we should see that immediately 5
in our console. 6
So this one is a little bit more challenging but there's nothing new here and you should be able to 7
complete it or at least give it a really good go. 8
So pause the video and complete the challenge now. 9
All right here's your first hint. 10
Inside our compose.ejs 11
currently we've only got an input and a button. 12
In order for this to actually make a post request to our server we're going to have to put it inside 13
a form so that when we submit the form we can pass over the value that the user typed into this input 14
over to our app.js. 15
So pause the video and see if you can use that knowledge to complete the challenge. 16
All right. 17
Back for another hint? 18
So let's add our form into our compose. 19
ejs and I'm going to put the input and the button inside that form. 20
Now you need to make sure that the button is of type submit so that when you actually click on it it 21
will submit all the content in the form. 22
Now the other thing you have to check is that your form has a method of post and that the action is 23
the route that you're going to handle 24
inside your app.js. 25
So a good one might be /compose. 26
So we post to the /compose route and we have an input that is of type text that needs to have 27
a name 28
and we have a button that submits the form. 29
So now see if that was enough for you to be able to complete the challenge. OK. 30
Here's a hint 31
3. In order for us to be able to tap into the value of the input that the user puts into this text 32
box 33
we have to give it a name. So let's call it something like post title because this is what we're going 34
to use a little bit later on. 35
Now it doesn't matter if you call it something else as long as you remember what the name for this input 36
was. 37
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
a post request to the /compose route. 39
Now currently we don't actually address what should happen when somebody makes a post request to that 40
route. 41
We only address what should happen when somebody makes a get request to that route. 42
So you're going to need to add a post method inside here to tell the server what it should do when somebody 43
makes a post request to the /compose route. See if that was enough for you to be able to now complete 44
the challenge.