← Angular learning path
Angular · Module 8 of 10

HTTP and RxJS

Call APIs with HttpClient and handle streams with RxJS Observables.

📖 Key ideas

  1. provideHttpClient() enables HttpClient.
  2. http.get<User[]>("/api/users") returns an Observable.
  3. Subscribe or use the async pipe: users$ | async.
  4. RxJS operators: map, filter, switchMap, catchError.
  5. Interceptors add auth headers or handle errors for all requests.
💡 Real-life example: An Observable is a YouTube subscription: new videos (values) arrive over time until you unsubscribe.
HttpClientAngular service for HTTP
ObservableStream of values over time
async pipeSubscribes in the template automatically
InterceptorCode that runs for every request