Bird
0
0

Which of the following is the correct way to continue request processing inside a NestJS middleware?

easy📝 Syntax Q12 of 15
NestJS - Middleware
Which of the following is the correct way to continue request processing inside a NestJS middleware?
AReturn the response directly
BCall <code>next()</code> function
CThrow an error to stop processing
DCall the route handler manually
Step-by-Step Solution
Solution:
  1. Step 1: Identify middleware flow control

    In NestJS, calling next() passes control to the next middleware or handler.
  2. Step 2: Eliminate incorrect options

    Returning response or throwing error stops flow; calling handler manually is not standard.
  3. Final Answer:

    Call next() function -> Option B
  4. Quick Check:

    Use next() to continue middleware chain [OK]
Quick Trick: Always call next() to move forward in middleware [OK]
Common Mistakes:
  • Forgetting to call next(), causing request hang
  • Trying to call handler directly inside middleware
  • Returning response without next() when not ending request

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes