File: angular-httpclient-and-other-data-fetching-clients.md | Updated: 11/15/2025
Search...
+ K
Auto
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Maintainers Partners Support Learn StatsBETA Discord Merch Blog GitHub Ethos Brand Guide
Documentation
Framework
Angular
Version
Latest
Search...
+ K
Menu
Getting Started
Guides & Concepts
API Reference
ESLint
Examples
Framework
Angular
Version
Latest
Menu
Getting Started
Guides & Concepts
API Reference
ESLint
Examples
On this page
Copy Markdown
Because TanStack Query's fetching mechanisms are agnostically built on Promises, you can use literally any asynchronous data fetching client, including the browser native fetch API, graphql-request, and more.
Using Angular's HttpClient for data fetching
--------------------------------------------
HttpClient is a powerful and integrated part of Angular, which gives the following benefits:
### Using observables in queryFn
As TanStack Query is a promise based library, observables from HttpClient need to be converted to promises. This can be done with the lastValueFrom or firstValueFrom functions from rxjs.
ts
@Component({
// ...
})
class ExampleComponent {
private readonly http = inject(HttpClient)
readonly query = injectQuery(() => ({
queryKey: ['repoData'],
queryFn: () =>
lastValueFrom(
this.http.get('https://api.github.com/repos/tanstack/query'),
),
}))
}
@Component({
// ...
})
class ExampleComponent {
private readonly http = inject(HttpClient)
readonly query = injectQuery(() => ({
queryKey: ['repoData'],
queryFn: () =>
lastValueFrom(
this.http.get('https://api.github.com/repos/tanstack/query'),
),
}))
}
Since Angular is moving towards RxJS as an optional dependency, it's expected that HttpClient will also support promises in the future.
Support for observables in TanStack Query for Angular is planned.
Comparison table
----------------
| Data fetching client | Pros | Cons | | --- | --- | --- | | Angular HttpClient | Featureful and very well integrated with Angular. | Observables need to be converted to Promises. | | Fetch | Browser native API, so adds nothing to bundle size. | Barebones API which lacks many features. | | Specialized libraries such as graphql-request | Specialized features for specific use cases. | If it's not an Angular library it won't integrate well with the framework. |
[###### Want to Skip the Docs?
Query.gg - The Official React Query Course
\
“If you’re serious about *really* understanding React Query, there’s no better way than with query.gg”—Tanner Linsley
Learn More](https://query.gg/?s=tanstack)
