Bird
0
0

Which method must be implemented inside an Angular HTTP interceptor class?

easy📝 Syntax Q3 of 15
Angular - HTTP Client
Which method must be implemented inside an Angular HTTP interceptor class?
Ahandle(req: HttpRequest<any>): void
BmodifyRequest(req: HttpRequest<any>): HttpRequest<any>
CsendRequest(req: HttpRequest<any>): Promise<any>
Dintercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>
Step-by-Step Solution
Solution:
  1. Step 1: Identify the required method signature

    The HttpInterceptor interface requires implementing the intercept method with parameters for request and next handler, returning an Observable.
  2. Step 2: Eliminate incorrect method signatures

    Other methods like handle, sendRequest, or modifyRequest are not part of the interceptor interface.
  3. Final Answer:

    intercept(req: HttpRequest, next: HttpHandler): Observable> -> Option D
  4. Quick Check:

    Interceptor method = intercept(...) [OK]
Quick Trick: Use intercept(req, next) returning Observable [OK]
Common Mistakes:
MISTAKES
  • Using void or Promise return types
  • Naming method other than intercept
  • Missing parameters in method

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes