← 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. How do you add custom HTTP headers to an HttpClient request?

    Answer: By passing an HttpHeaders object via the headers option

    You construct an HttpHeaders instance with key-value pairs and pass it through the headers property of the request options object.

  2. What is the purpose of HttpClientTestingModule in Angular unit tests?

    Answer: To provide a mock HTTP backend so requests can be flushed and asserted

    HttpClientTestingModule replaces the real backend with TestingBackend, letting you expect, flush, and verify requests without real network calls.

  3. How do you cancel an in-flight HTTP request in Angular?

    Answer: Unsubscribe from the Observable returned by HttpClient

    Unsubscribing from the HttpClient Observable triggers teardown logic that aborts the underlying XHR request.

  4. What does setting withCredentials: true in an HttpClient request do?

    Answer: Includes cookies and authorization headers in cross-origin requests

    withCredentials: true instructs the browser to send cookies, HTTP authentication headers, and TLS client certificates with cross-origin requests.

  5. How do you configure HttpClient to return the raw response body as a plain string instead of parsed JSON?

    Answer: responseType: 'text'

    Setting responseType: 'text' tells HttpClient to skip JSON parsing and return the response body as a raw string.

  6. Which RxJS operator automatically re-issues an HTTP request up to 3 times when it fails?

    Answer: retry(3)

    retry(3) resubscribes to the source observable — re-issuing the HTTP request — up to 3 times before propagating the error.

  7. How should you send a JavaScript object as a JSON body in an HttpClient.post() request?

    Answer: Pass the plain object as the body argument; Angular serializes it automatically

    HttpClient detects a plain object body, serializes it to JSON, and sets the Content-Type: application/json header automatically.