Skip to content
Learn Netverks

Lesson

Step 30/36 83% through track

http-client

HttpClient

Last reviewed May 28, 2026 Content v20260528
Track mode
client_angular
Means
In-browser Angular TS
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches HttpClient: the concepts, APIs, and habits you need before advancing in Angular.

Without HttpClient, you will struggle to read or extend Angular codebases and playground exercises.

You will apply HttpClient in contexts like: REST clients, interceptors, and error handling in line-of-business dashboards.

Write TypeScript with decorators, click Run—Angular 19 loads from CDN, use the Ng global and mountApp(Component) with selector app-root; printOutput feeds the terminal.

Toward the end of the track—consolidate before capstone-style review lessons.

HttpClient (@angular/common/http) performs REST calls and returns Observables. Register it with provideHttpClient() at bootstrap in CLI apps.

Typical flow

  1. Inject HttpClient in a service
  2. Call get<User[]>('/api/users')
  3. Subscribe in the service or expose to templates via async pipe
  4. Map HTTP errors to user-visible state—never fail silently

Interceptors

Interceptors attach auth headers, log requests, or retry failures across the app without duplicating code in every service.

Important interview questions and answers

  1. Q: Why Observables instead of Promises only?
    A: Cancellation, composition with RxJS operators, and multiple emissions (progress events).
  2. Q: Where handle 401 responses?
    A: Often in an interceptor that redirects to login or refreshes tokens.

Self-check

  1. What does the playground log for a GET users call?
  2. Why pair HttpClient with the async pipe in templates?

Challenge

HTTP shape

  1. Run the default code.
  2. Add a second printOutput describing error handling.

Done when: terminal shows the Observable-based GET description.

Pitfall: Forgetting error handling in subscribe—always map HTTP failures to user-visible state.

Interview prep

What does HttpClient return?

Observables of HTTP events/bodies—compose with RxJS operators and unsubscribe via async pipe or takeUntil.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • HttpClient returns?
  • Interceptor use?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump