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 trialAlexei Parphyonov
34,128 PointsDon't get 'One and a half' printed to the console
Here is what I've got for the Middleware section (below App settings, above Routes).
app.use((req, res, next) => { console.log('One'); next(); }, (req, res, next) => { console.log('One and a half'); next(); }); app.use((req, res, next) => { console.log('Two'); next(); });
And I can't get 'One and a half' printed. Always get 'One Two One Two' in the console. Reduplication is thanks to redirecting I believe, but how do I get 'One and a half' anyways?
1 Answer
Tom Geraghty
24,174 PointsI tried formatting your code and putting in a code block so I could find any errors. I don't see any. Can you copy in the rest of your server.js file so we can see if there's something else causing the problem?
Here is your code, pasted in from above, formatted:
app.use(
(req, res, next) => {
console.log('One');
next();
},
(req, res, next) => {
console.log('One and a half');
next();
});
app.use((req, res, next) => {
console.log('Two'); next();
});