Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Practice ExpressJS: Middleware!
You have completed Practice ExpressJS: Middleware!
Preview
This video shows my solution to the challenge.
Resources
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
you can see my solution here and
go back and try it again.
0:00
To get started,
I imported the users array from data.json.
0:00
Then I defined a named export that
provides our middleware function and
0:05
named it authUser.
0:09
I immediately checked if there was a query
on the request object named username,
0:11
and if not, I redirected
the response to the forbidden route.
0:16
Because this conditional statement
only has one action to execute,
0:20
I've omitted the curly braces and
placed it all on one line for readability.
0:24
Next, I defined a variable and
0:28
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