Node.js Output Prediction Medium +20 XP
Middleware Order
What does next() do in Express middleware?
Node.jsRead-only
app.use((req, res, next) => {
console.log(req.method);
next();
});What is the output?
Show answer and explanation
Answer: Passes control to the next middleware
next() passes control to the next middleware function in the chain. Without it, the request would hang.
Hint: What happens after logging?
What this challenge tests
Output Prediction in Node.js: express, middleware.