Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

README.md

14 lines747 Bytes

1# TanStack Angular Query Simple Example
2​
3Fetches a single GitHub repository and shows its stats.
4​
5## How it works
6​
7- `src/app/components/simple-example.component.ts` calls `injectQuery` with `queryKey: ['repoData']` and a `queryFn` that fetches the `TanStack/query` repository with `HttpClient` and converts it with `lastValueFrom`.
8- `src/app/components/simple-example.component.html` renders from the query's signals: `isPending()`, `isError()` with `error()`, and `data()` for the repository's name, description and counts.
9- `src/app/app.config.ts` registers a `QueryClient` with `provideTanStackQuery` and `withDevtools()`, and provides `HttpClient` with `provideHttpClient(withFetch())`.
10​
11To run this example:
12​
13- `npm install`
14- `npm start`