Angular - HTTP ClientWhich method must be implemented inside an Angular HTTP interceptor class?Ahandle(req: HttpRequest<any>): voidBmodifyRequest(req: HttpRequest<any>): HttpRequest<any>CsendRequest(req: HttpRequest<any>): Promise<any>Dintercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>Check Answer
Step-by-Step SolutionSolution:Step 1: Identify the required method signatureThe HttpInterceptor interface requires implementing the intercept method with parameters for request and next handler, returning an Observable.Step 2: Eliminate incorrect method signaturesOther methods like handle, sendRequest, or modifyRequest are not part of the interceptor interface.Final Answer:intercept(req: HttpRequest, next: HttpHandler): Observable> -> Option DQuick Check:Interceptor method = intercept(...) [OK]Quick Trick: Use intercept(req, next) returning Observable [OK]Common Mistakes:MISTAKESUsing void or Promise return typesNaming method other than interceptMissing parameters in method
Master "HTTP Client" in Angular9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More Angular Quizzes Angular Change Detection - Default change detection strategy - Quiz 15hard Angular Change Detection - When to use OnPush - Quiz 5medium Reactive Forms - Why reactive forms are preferred - Quiz 6medium Reactive Forms - FormArray for dynamic fields - Quiz 13medium Routing - Why routing is needed for SPAs - Quiz 5medium RxJS Operators - combineLatest and forkJoin for combining - Quiz 2easy RxJS Operators - combineLatest and forkJoin for combining - Quiz 14medium Services and Dependency Injection - Creating a service with CLI - Quiz 2easy Services and Dependency Injection - @Injectable decorator and providedIn - Quiz 3easy Template-Driven Forms - Form validation with template attributes - Quiz 8hard