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 Understanding Express Middleware!
You have completed Understanding Express Middleware!
Preview
The `next()` function is important in Express middleware. Let's examine what it does and how to use it.
JavaScript Error 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
But it's not the only way to
end middleware, as we'll see.
0:00
Next also provides a way to handle errors.
0:01
Here's the state of the code as
we left it in the last video.
0:04
Let's see what happens when I remove
next from the first function.
0:08
I'll open a new tab and request our app.
0:14
The page is not loading,
0:18
that's because the app hangs when
middleware is not closed out with next.
0:20
The app is waiting indefinitely for
next to be called right here.
0:24
Express relies on the next function
to know when to move forward.
0:29
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