Bird
0
0

What will happen if a guard's canActivate method returns a Promise that resolves to false?

medium📝 component behavior Q5 of 15
NestJS - Guards
What will happen if a guard's canActivate method returns a Promise that resolves to false?
AThe request will be denied and not proceed
BThe request will proceed immediately
CThe server will crash
DThe request will be delayed indefinitely
Step-by-Step Solution
Solution:
  1. Step 1: Understand async return behavior

    Returning a Promise is allowed; the framework waits for resolution.
  2. Step 2: Interpret resolved value false

    If the Promise resolves to false, the guard denies the request.
  3. Final Answer:

    Request is denied and does not proceed -> Option A
  4. Quick Check:

    Promise resolving false denies request [OK]
Quick Trick: Async canActivate false denies request [OK]
Common Mistakes:
  • Thinking request proceeds despite false
  • Expecting server crash on Promise
  • Assuming indefinite delay

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes