Bird
0
0

Consider this NestJS middleware:

medium📝 Predict Output Q4 of 15
NestJS - Middleware
Consider this NestJS middleware:
function timingLogger(req, res, next) { console.log('Start'); next(); console.log('End'); }

Which message will appear first in the console when a request is processed?
A'Start'
B'End'
CBoth appear simultaneously
DNeither appears
Step-by-Step Solution
Solution:
  1. Step 1: Analyze middleware flow

    Console logs 'Start' before calling next().
  2. Step 2: next() passes control to next middleware or handler

    After next() completes, 'End' is logged.
  3. Final Answer:

    'Start' is logged first -> Option A
  4. Quick Check:

    Logs before next() run first [OK]
Quick Trick: Logs before next() run first [OK]
Common Mistakes:
  • Assuming 'End' logs before 'Start'
  • Thinking next() is synchronous and blocks logging
  • Believing logs appear simultaneously

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes