NestJS · Junior · Question 39 of 75
What is the job of a guard?
- 1Retry failed database queries
- ✓Correct answer: Decide whether a request may reach the handler, typically for authentication or roles
- 3Format the response
Explanation
A guard implements canActivate() and returns true or false (or throws). Returning false gives 403 Forbidden by default.