Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
A solution to the challenge from the last video.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
How did it go?
0:00
Don't feel bad if you weren't
able to complete it all.
0:01
Even if you got some of the features
completed, you did well.
0:04
Now, I'll go over how I
created the goodbye button.
0:07
To create the button itself,
0:12
I've added a form to the index.pug
file right under the greeting.
0:14
I set its action to /goodbye
which is the new goodbye route.
0:21
The method is post and
in the form I've got one submit button.
0:27
It has the text goodbye.
0:34
In app.js I added a new post route under
the hello post route called goodbye.
0:38
I use the clear cookie method to
remove the cookie's username value,
0:48
then I redirected to the hello route.
0:53
Let's see what we have in the browser now.
0:58
I go to the Hello route and
then I type in my name and hit enter.
1:02
I'm redirected to the Home route and
my name is displayed.
1:09
Notice I can't get to
the Hello route anymore.
1:14
And here's the Goodbye
button I implemented.
1:20
If I click it,
I'm redirected to the Hello page.
1:24
If I try and visit the index route,
I'm redirected to the Hello page.
1:30
Great, now we have the app that stores and
1:37
erases the cookie, it also redirects
based on the cookies value.
1:39
We've covered a lot of
ground in this process.
1:44
Well done for sticking with it.
1:47
Next up, let's dive deeper into
a fundamental feature of Express,
1:49
called Middleware.
1:53
See you there.
1:54
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up