-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b051739
commit a76a483
Showing
5 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Retries | ||
|
||
From time to time, fetch requests may fail. This can happen for a variety of reasons, like a network error or a server error. In these cases, you may want to retry the request a few times before giving up. | ||
|
||
You can configure retries for a single request by passing a `retry` option to the `useApiPartyData` and `$apiParty` composables. It can be a number, `false` or `undefined`, either reactive or not: | ||
|
||
```ts | ||
const retry: MaybeRef<number | false | undefined> | ||
``` | ||
Example: | ||
```ts | ||
// Retry failed requests 3 times | ||
const { data } = await useJsonPlaceholderData('posts/1', { | ||
retry: 3, | ||
}) | ||
``` | ||
|
||
By default, the `retry` option is set to `undefined`, meaning that no retries will be attempted. | ||
|
||
::: info | ||
These examples assume that you have set up an API endpoint called `jsonPlaceholder`: | ||
|
||
```ts | ||
// `nuxt.config.ts` | ||
export default defineNuxtConfig({ | ||
modules: ['nuxt-api-party'], | ||
|
||
apiParty: { | ||
endpoints: { | ||
jsonPlaceholder: { | ||
url: 'https://jsonplaceholder.typicode.com' | ||
} | ||
} | ||
} | ||
}) | ||
``` | ||
|
||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"name": "docs", | ||
"type": "module", | ||
"private": true, | ||
"scripts": { | ||
"dev": "vitepress dev", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters