Angular's HttpClient is the built-in service for communicating with backend APIs over HTTP. This lesson covers setting it up and making basic typed requests.
What Is HttpClient?
HttpClient is an injectable Angular service, from @angular/common/http, that wraps the browser's fetch/XMLHttpRequest APIs with a consistent, Observable-based interface, request/response typing, interceptors, and testing utilities.
Every request returns an Observable that emits once (for a typical request/response) and completes, you subscribe to it (or, more often, combine it with the async pipe) to receive the result.
Passing a generic type argument to HttpClient methods gives you compile-time safety on the response shape, catching mismatched property names before they become runtime bugs.
Query parameters and custom headers are passed through the options object on any HttpClient method, Angular encodes them correctly rather than requiring manual string concatenation.
Rather than manually subscribing and storing data in a class property, exposing the request Observable directly and rendering it with the async pipe avoids manual subscription management entirely.
Forgetting to call .subscribe() (or use the async pipe), Observables from HttpClient do nothing until subscribed to.
Not registering provideHttpClient() before injecting HttpClient anywhere in the app.
Calling HttpClient methods directly from components instead of wrapping them in a dedicated service.
Manually building query strings instead of using the built-in params option.
Key Takeaways
HttpClient provides an Observable-based, typed interface for making HTTP requests.
provideHttpClient() must be registered once before the service can be injected anywhere.
Generic type parameters on request methods give compile-time safety for response shapes.
The async pipe is often the cleanest way to render HTTP responses without manual subscription code.
Pro Tip
Wrap every HttpClient call in a dedicated service method with a clear, typed return value; it keeps API details out of components and makes it trivial to swap in a mock service during testing.
You now understand Angular's HttpClient basics. Next, learn practical API Calls patterns for real-world data fetching.