Bird
0
0

Which of the following is the correct syntax to create a basic TimeoutInterceptor class in NestJS?

easy📝 Syntax Q3 of 15
NestJS - Interceptors

Which of the following is the correct syntax to create a basic TimeoutInterceptor class in NestJS?

Aexport class TimeoutInterceptor implements NestInterceptor { intercept(context, next) { return next.handle().pipe(timeout(5000)); } }
Bexport class TimeoutInterceptor { intercept(context, next) { return next.handle().pipe(timeout(5000)); } }
Cexport class TimeoutInterceptor implements NestInterceptor { intercept(context) { return next.handle().pipe(timeout(5000)); } }
Dexport class TimeoutInterceptor implements NestInterceptor { intercept(next) { return next.handle().pipe(timeout(5000)); } }
Step-by-Step Solution
Solution:
  1. Step 1: Check interface implementation and method signature

    The interceptor must implement NestInterceptor and have intercept(context, next) method.
  2. Step 2: Verify usage of next.handle() and RxJS timeout

    The method should return next.handle().pipe(timeout(5000)) to apply timeout.
  3. Final Answer:

    export class TimeoutInterceptor implements NestInterceptor { intercept(context, next) { return next.handle().pipe(timeout(5000)); } } -> Option A
  4. Quick Check:

    Correct syntax = export class TimeoutInterceptor implements NestInterceptor { intercept(context, next) { return next.handle().pipe(timeout(5000)); } } [OK]
Quick Trick: Implement NestInterceptor with intercept(context, next) method [OK]
Common Mistakes:
  • Missing interface implementation
  • Wrong method parameters
  • Omitting next.handle() call

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes