Loading topic
HttpClient (get, post, put, delete and the others) returns an RxJS Observable rather than a Promise. That choice affects when requests are sent, how many are sent, and how you cancel them. This chapter explains how that works so the rest of the tutorial makes 2 min readbootstrapApplication, and how dependency injection supplies services through providers. HttpClient is a service, so before any component or service can inject it, the application needs a provider for it. In a standalone2 min readprovideHttpClient() as shown in the previous chapter. Here you will move HTTP calls out of components and into a dedicated data service.2 min readprovideHttpClient() in your application config and a TodoService that injects HttpClient, both set up in the previous chapters. You should also be comfortable with TypeScript generics and the RxJS pipe method.2 min readTodoService from the previous chapters, with HttpClient injected and a typed getTodos method. You should also know what an HTTP method means and how to call subscribe on an Observable.2 min readTodoService that injects HttpClient and makes typed GET requests, as built in the earlier chapters. You should also be comfortable with TypeScript optional properties and basic HTTP concepts such as query strings and request headers.2 min readTodoService that injects HttpClient and returns typed Observables, as built in the earlier chapters. You should also know how pipe chains RxJS operators.3 min readTodoService whose getTodos(page) method returns Observable<Todo[]>. It also assumes you know standalone components and the built-in @if and @for control flow blocks. The question here is how a component reads that Observable and renders the data with2 min readTodoService from earlier chapters and know how HttpClient.get<T>() returns an Observable<T>. It also assumes you know the basics of HTTP headers and status codes.2 min read401. Writing that code into each service method spreads it thin and makes it easy to miss one call. An interceptor is a function that sits between your services and the network. It sees each outgoing r2 min readHttpClient GET call in a service and display the result with the async pipe or toSignal. You should also know the RxJS pipe method. Here you will learn how to cancel requests that are no longer needed and how to run several requests together.3 min readwithInterceptors. You should also be comfortable with TypeScript generics and the RxJS retry operator.2 min readobserve and responseType options. It also assumes you can use RxJS map and filter inside pipe. By default, HttpClient emits a single value: the response body. That is all most requests need. A large f2 min readdescribe, it and expect, and that you have the TodoService from earlier chapters. A unit test for an HTTP service should never reach a real server. A real server makes tests slow and flaky, and the results depend on data you don't2 min read