A. Missing parameter name inside @Param() decorator.
B. Route path should not have colon before orderId.
C. Method should use @Query instead of @Param.
D. Return statement syntax is invalid.
Solution
Step 1: Check @Param usage
The @Param() decorator without an argument returns an object of all params, not a single string.
Step 2: Identify mismatch in parameter type
The method expects orderId as a string, but @Param() without argument returns an object, causing a type mismatch.
Final Answer:
Missing parameter name inside @Param() decorator. -> Option A
Quick Check:
@Param needs name for single param = B [OK]
Hint: Use @Param('name') for single param, else get object [OK]
Common Mistakes:
Omitting parameter name in @Param() when expecting string
Confusing @Param with @Query
Thinking colon is wrong in route path
5. You want to create a NestJS route that accepts two parameters: category and itemId. Which of the following route paths and method signatures correctly captures both parameters?
hard
A. @Get('shop/:category/:itemId') getItem(@Body('category') category: string, @Body('itemId') itemId: string)
B. @Get('shop/:category/:itemId') getItem(@Param('category') category: string, @Param('itemId') itemId: string)
C. @Get('shop/:category/:itemId') getItem(@Query('category') category: string, @Query('itemId') itemId: string)
D. @Get('shop/:category/:itemId') getItem(@Param() params: string)
Solution
Step 1: Verify route path with two parameters
The path 'shop/:category/:itemId' correctly defines two dynamic route parameters.
Step 2: Check method parameters for correct decorators
Using @Param('category') and @Param('itemId') extracts each parameter individually as strings.
Final Answer:
@Get('shop/:category/:itemId') with getItem(@Param('category') category: string, @Param('itemId') itemId: string) -> Option B
Quick Check:
Use @Param('name') for each route param = D [OK]
Hint: Use @Param('name') for each route parameter [OK]
Common Mistakes:
Using @Param() with string instead of object
Using @Query or @Body instead of @Param for route params
Not matching parameter names exactly
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.