0
0
NestJSframework~10 mins

Timeout interceptor in NestJS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the correct NestJS module for interceptors.

NestJS
import { [1] } from '@nestjs/common';
Drag options to blanks, or click blank then click option'
AInterceptor
BInjectable
CController
DModule
Attempts:
3 left
💡 Hint
Common Mistakes
Using @Interceptor instead of @Injectable
Forgetting to import @Injectable
2fill in blank
medium

Complete the code to implement the NestJS interceptor interface.

NestJS
export class TimeoutInterceptor implements [1]<any> {
Drag options to blanks, or click blank then click option'
ANestInterceptor
BCanActivate
CExceptionFilter
DPipeTransform
Attempts:
3 left
💡 Hint
Common Mistakes
Using PipeTransform instead of NestInterceptor
Confusing with ExceptionFilter
3fill in blank
hard

Fix the error in the method signature to correctly implement the intercept method.

NestJS
intercept(context: ExecutionContext, next: [1]): Observable<any> {
Drag options to blanks, or click blank then click option'
AResponseHandler
BNextFunction
CRequestHandler
DCallHandler
Attempts:
3 left
💡 Hint
Common Mistakes
Using NextFunction which is from Express middleware
Using RequestHandler or ResponseHandler which do not exist in NestJS interceptors
4fill in blank
hard

Fill in the blank to apply a timeout of 5000 milliseconds to the observable.

NestJS
return next.handle().pipe(timeout([1]));
Drag options to blanks, or click blank then click option'
A5000
B3000
C10000
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 which disables timeout
Using too low or too high values not matching 5 seconds
5fill in blank
hard

Fill all three blanks to import the timeout operator, catchError operator, and throwError function from RxJS.

NestJS
import { [1], [2] } from 'rxjs/operators';
import { [3] } from 'rxjs';
Drag options to blanks, or click blank then click option'
Atimeout
BcatchError
CthrowError
Dmap
Attempts:
3 left
💡 Hint
Common Mistakes
Including map instead of throwError
Missing catchError which handles errors