โ† All Angular Web Framework Flashcard Decks

HTTP Client & API Integration Flashcards

7 cards from real Angular Web Framework practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 HTTP Client & API Integration flashcards as text
  1. Which Angular module must be imported into AppModule to enable HttpClient throughout an application?

    Answer: HttpClientModule

    HttpClientModule (from @angular/common/http) registers the HttpClient service and must be imported in AppModule or a shared module.

  2. What return type does HttpClient.get() produce by default?

    Answer: Observable

    HttpClient.get() returns an Observable that emits the parsed response body once the request completes.

  3. What is the primary purpose of an HttpInterceptor in Angular?

    Answer: To intercept and transform HTTP requests and responses globally

    HttpInterceptor sits in the request pipeline and lets you add headers, log calls, handle errors, or modify responses globally.

  4. Which HttpClient request option causes it to return the full HTTP response including status code and headers?

    Answer: observe: 'response'

    Setting observe: 'response' returns an HttpResponse object containing the status, headers, and parsed body.

  5. How do you pass query string parameters to an HttpClient.get() request in Angular?

    Answer: Use the params option with an HttpParams object or plain object

    The params option accepts an HttpParams instance or a plain key-value object that Angular safely encodes and appends to the URL.

  6. Which RxJS operator is most appropriate for catching and recovering from HTTP errors in an Angular service?

    Answer: catchError

    catchError intercepts an error notification in the observable chain and lets you return a fallback observable or rethrow a transformed error.

  7. What decorator is required on a class to allow Angular's DI system to inject HttpClient into it?

    Answer: @Injectable()

    @Injectable() marks a class as a participant in Angular's dependency injection, enabling constructor injection of HttpClient and other services.