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

JavaScript Express Basics Middleware Handling 404 Errors

Does this mean the order in which you write your requests matter?

.

1 Answer

James Crosslin
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
James Crosslin
Full Stack JavaScript Techdegree Graduate 16,882 Points

Nobody answered this question a year ago, but I think that it's important to address this: yes, the order in which you write your routes is important. In one of the videos in this module, we put an unavoidable error middleware before our routes, and it did not allow us to get to our routes. We threw the error, and that made accessing any following routes that did not accept the '''err''' object as a parameter impossible. Moving our error middleware past our routes then allowed us to access those routes, only throwing an error when none of our routes matched the request.