Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialhaozhuohuang
2,590 Pointscalling next()
I am wondering why in app.use("/questions", routes); we do not have to call next().... Thanks!
1 Answer
Donnie Reese
17,211 PointsTo my understanding, when you call 'routes', it's calling all of the routes.js page, with all of it's routes, under the "/questions" path.
Also, those are not the same as separate middleware instances. They are all routes, waiting to be called, not all being called sequentially as middleware calls would be. I believe.
I hope that helps.
Steve Gardner
17,786 PointsSteve Gardner
17,786 PointsThis method is simply sending the request to our routing file. You can call next() from within the routes for many different reasons such as setting params, using multiple callbacks, or error handling.