Seamless data fetching with ht... Note

Seamless data fetching with httpResource

Angular is introducing new APIs, including the experimental resource() API, which allows developers to expose the results of asynchronous operations as signals. The httpResource API is built on top of the resource primitive and uses HttpClient as a loader, making it easier to facilitate HTTP requests. httpResource acts as a frontend for @angular/common/http and makes HTTP requests through the Angular HTTP stack, including interceptors. By default, an httpResource performs a GET request and returns an unknown typed JSON response. It differs from the HttpClient as it initiates the request eagerly, and if any source signals in the request computation change, a new HTTP request will be made. httpResource allows for advanced requests by defining a request object similar to HttpClient's request. The API has dedicated methods available for other response types, such as text, blob, and arrayBuffer. An httpResource exposes several signals, including value, status, error, isLoading, headers, statusCode, and progress. The httpResource offers direct integration with schema validation libraries like Zod or Valibot for type safety. The httpResource is available as an experimental API in Angular v19.2 and is not yet ready for production, but developers are encouraged to try it out and provide feedback.
CdXz5zHNQW_4lkhfMb8Ye.jpeg