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 trial
How does express determine the 'next' parameter to pass into each middleware function?
I'm curious as to how express knows what to pass as each next parameter. Is this simply done in order of app.use() functions, or is there more to it?
Tom Geraghty24,174 Points
The next parameter is a callback function. It's called next by convention to make writing and reading applications using this convention easier.
If you think in Promises, you can think of this particular callback as being called when the Promise has been resolved and the program is free to move on to the next step in processing the application's logic.