Bird
0
0

Why is it important that guards in NestJS return a boolean or a Promise?

hard📝 Conceptual Q10 of 15
NestJS - Authentication
Why is it important that guards in NestJS return a boolean or a Promise?
ABecause guards are only allowed to return synchronous values
BBecause guards must always return true to avoid errors
CBecause NestJS uses the return value to decide if route execution proceeds
DBecause returning other types causes the server to crash
Step-by-Step Solution
Solution:
  1. Step 1: Understand guard return types

    Guards return boolean or Promise to indicate allow or deny access.
  2. Step 2: Explain why this matters

    NestJS uses this return value to decide if the route handler should run or be blocked.
  3. Final Answer:

    Because NestJS uses the return value to decide if route execution proceeds -> Option C
  4. Quick Check:

    Guard return controls route access [OK]
Quick Trick: Return boolean or Promise in guards [OK]
Common Mistakes:
  • Thinking guards must always return true
  • Believing other return types cause crashes
  • Assuming guards cannot return promises

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes