|
Download react-query/docs/framework/angular/guides/query-retries.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/docs/framework/angular/guides/query-retries.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/docs/framework/angular/guides/query-retries.md
-
curl -L -o query-retries.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/docs/framework/angular/guides/query-retries.md
1.5 kB
| id: query-retries | |
| title: Query Retries | |
| ref: docs/framework/react/guides/query-retries.md | |
| replace: | |
| { | |
| 'Provider': 'Plugin', | |
| 'useQuery': 'injectQuery', | |
| 'useMutation': 'injectMutation', | |
| } | |
| [//]: # 'Info' | |
| [//]: # 'Info' | |
| [//]: # 'Example' | |
| ```ts | |
| import { injectQuery } from '@tanstack/angular-query-experimental' | |
| // Make a specific query retry a certain number of times | |
| const result = injectQuery(() => ({ | |
| queryKey: ['todos', 1], | |
| queryFn: fetchTodoListPage, | |
| retry: 10, // Will retry failed requests 10 times before displaying an error | |
| })) | |
| ``` | |
| [//]: # 'Example' | |
| [//]: # 'Example2' | |
| ```ts | |
| // Configure for all queries | |
| import { | |
| QueryCache, | |
| QueryClient, | |
| QueryClientProvider, | |
| } from '@tanstack/angular-query-experimental' | |
| const queryClient = new QueryClient({ | |
| defaultOptions: { | |
| queries: { | |
| retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 30000), | |
| }, | |
| }, | |
| }) | |
| bootstrapApplication(AppComponent, { | |
| providers: [provideTanStackQuery(queryClient)], | |
| }) | |
| ``` | |
| [//]: # 'Example2' | |
| Though it is not recommended, you can obviously override the `retryDelay` function/integer in both the Provider and individual query options. If set to an integer instead of a function the delay will always be the same amount of time: | |
| [//]: # 'Example3' | |
| ```ts | |
| const result = injectQuery(() => ({ | |
| queryKey: ['todos'], | |
| queryFn: fetchTodoList, | |
| retryDelay: 1000, // Will always wait 1000ms to retry, regardless of how many retries | |
| })) | |
| ``` | |
| [//]: # 'Example3' | |