Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a retry option to UseApiDataOptions #29

Closed
1 of 3 tasks
klemenstraeger opened this issue Jun 21, 2023 · 2 comments
Closed
1 of 3 tasks

Add a retry option to UseApiDataOptions #29

klemenstraeger opened this issue Jun 21, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@klemenstraeger
Copy link

Describe the feature

Im currently using something like this in my project to retry a failed fetch.

const fetchData = async () => {
    let tries = 0
    const maxTries = 3

    const { refresh, error, data } = await useApiData(
        "path/to/api",
    );
    while (error.value && tries < maxTries) {
        tries++;
        await refresh();
    }
    if (error.value) {
        //handle error..
    }
    return data.value
}

My suggstion would be to add an option to UseApiDataOptions to enable retries if a fetch fails.

await useApiData(
    "path/to/api",
    {
        retries: 3
    }
)

Thanks !

Additional information

  • Would you be willing to help implement this feature?
  • Can you think of other implementations of this feature?

Final checks

@klemenstraeger klemenstraeger changed the title Add a retry option to opts Add a retry option to UseApiDataOptions Jun 21, 2023
@johannschopplich
Copy link
Owner

Good idea. PR welcome. 🙋‍♂️

@johannschopplich johannschopplich added enhancement New feature or request and removed pending triage labels Jun 25, 2023
@johannschopplich
Copy link
Owner

@klemenstraeger @m0zz094 @linshujuan This feature has been implemented: https://nuxt-api-party.byjohann.dev/guide/retries.html

@johannschopplich johannschopplich changed the title Add a retry option to UseApiDataOptions Add a retry option to UseApiDataOptions Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants