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

Recommendations for axios retry condition #25

Conversation

weotch
Copy link
Member

@weotch weotch commented Sep 15, 2022

I made some pretty big changes to your #22, take a look here:

  • Imported functions directly from https://github.com/softonic/axios-retry rather than copying the code over
  • Moved the logic out of helpers (all exported methods from helper files get injected into the Nuxt $context, which we don't want)
  • Adding retrying functionality via Nuxt plugin, which I found was required in order to use other functions in my retryCondition due to how Nuxt module options get serialized. This also lets us mixin the retry functionality into instances of $axios created by $axios.create()
  • Made a demo component to verify it was working as expected.

One thing I discovered in doing this was that the interceptors that are created by axios retry are not propagated when new Axios clients are created, like we do in @cloak-app/craft. So after this merged, we'll have to add some code to that package to re-apply retrying to that packages axios instances 😓 . I made BKWLD/cloak-craft#14 for this.

Moving code into the Nuxt module and importing more from axios-retry
Functions could not be used from the nuxt/module module options.  Also, the retry would not be persisted when new clients were created, like the Craft client.
@codesandbox
Copy link

codesandbox bot commented Sep 15, 2022

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@lemoswilson lemoswilson merged commit 49069d0 into add-axios-retry-condition Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants