NestJS - InterceptorsWhy is it important that Exception Mapping Interceptors return observables and do not convert them to promises or other types?ABecause promises cannot handle errorsBBecause observables are faster than promisesCBecause converting to promises causes memory leaksDBecause NestJS expects interceptors to return observables to maintain reactive flowCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand NestJS interceptor expectationsNestJS interceptors work with RxJS observables to handle asynchronous streams.Step 2: Importance of returning observablesReturning observables preserves the reactive pipeline and allows operators like catchError to work properly.Final Answer:Because NestJS expects interceptors to return observables to maintain reactive flow -> Option DQuick Check:Interceptors must return observables for reactive flow [OK]Quick Trick: Return observables in interceptors to keep reactive streams [OK]Common Mistakes:Converting observables to promises inside interceptorsAssuming promises handle errors betterIgnoring NestJS reactive design
Master "Interceptors" in NestJS9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More NestJS Quizzes Authentication - JWT strategy - Quiz 11easy Authentication - JWT strategy - Quiz 14medium Authentication - Refresh token pattern - Quiz 2easy Database with Prisma - Prisma Client usage - Quiz 10hard Database with Prisma - Schema definition - Quiz 11easy Database with TypeORM - TypeORM module setup - Quiz 3easy Guards - Guard interface (canActivate) - Quiz 5medium Guards - Guard interface (canActivate) - Quiz 4medium Interceptors - Cache interceptor - Quiz 7medium Middleware - Functional middleware - Quiz 15hard