Bird
0
0

What is wrong with this usage of JwtAuthGuard? ```typescript @Get('info') @UseGuards() getInfo() { return { info: 'details' }; } ```

medium📝 Debug Q7 of 15
NestJS - Guards
What is wrong with this usage of JwtAuthGuard? ```typescript @Get('info') @UseGuards() getInfo() { return { info: 'details' }; } ```
A@UseGuards() is missing the JwtAuthGuard class inside
B@UseGuards() cannot be used on GET methods
CgetInfo method must be async
DJwtAuthGuard must be imported from '@nestjs/jwt'
Step-by-Step Solution
Solution:
  1. Step 1: Check @UseGuards decorator usage

    @UseGuards() requires guard classes as arguments.
  2. Step 2: Identify missing guard class

    Here, JwtAuthGuard is not passed inside @UseGuards().
  3. Final Answer:

    @UseGuards() is missing the JwtAuthGuard class inside -> Option A
  4. Quick Check:

    @UseGuards needs guard class argument [OK]
Quick Trick: Always pass guard class inside @UseGuards() [OK]
Common Mistakes:
  • Leaving @UseGuards empty
  • Thinking @UseGuards can't be on GET
  • Assuming method must be async unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes