Put in order · NestJS course · Module 2: Routing and Request Lifecycle

Getting the Request in a Guard

Arrange the elements of retrieving the request object in a guard's canActivate method:

Items to put in order

  • context.switchToHttp()
  • const request =
  • .getRequest()
Show the answer

Correct order:

  1. const request =
  2. context.switchToHttp()
  3. .getRequest()