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

index.ts

30 lines954 Bytes

1import '@angular/compiler'
2import 'zone.js'
3import { bootstrapApplication } from '@angular/platform-browser'
4import { provideAngularQuery } from '@tanstack/angular-query-experimental'
5import { QueryClient } from '@tanstack/angular-query-experimental'
6import axios from 'axios'
7import { DefaultQueryFunctionExampleComponent } from './default-query-function-example.component'
8import type { QueryFunction } from '@tanstack/angular-query-experimental'
9​
10// Define a default query function that will receive the query key
11const defaultQueryFn: QueryFunction = async ({ queryKey }) => {
12 const { data } = await axios.get(
13 `https://jsonplaceholder.typicode.com${queryKey[0]}`,
14 )
15 return data
17​
18bootstrapApplication(DefaultQueryFunctionExampleComponent, {
19 providers: [
20 provideAngularQuery(
21 new QueryClient({
22 defaultOptions: {
23 queries: {
24 queryFn: defaultQueryFn,
25 },
26 },
27 }),
28 ),
29 ],
30})