softonic / axios-retry

Axios plugin that intercepts failed requests and retries them whenever possible
Other
1.9k stars 167 forks source link

Make retryCondition accept a promise #163

Closed Calamari closed 3 years ago

Calamari commented 3 years ago

Status Quo:

If you have a call that fails with an 401 because of you cannot use axios-retry for this, since there is no way to tell how long a silent token refresh will take (so we could do it with retry-delay) or if it works at all (so we know what to put in retryCondition).

Solution:

The logical choice is, that retryCondition would optionally accept a function that returns a promise instead of boolean. And only if that succeeds (and returns true), we do the retry. That way we could easily accompany such use cases (as happened already, example with #56).

Since no one asked for this PR, I still needed it, so have done it. If there is something you would like to have changed, I will gladly do it, so we can move back to the original node module instead of loading it via fork.

tjxnor commented 3 years ago

Need this as well. Was looking to suggest a pull request as it is a common requirement for 401 errors and async token refresh.

shivaksk1 commented 3 years ago

@Calamari any progress in merging the PR? We too require this for managing access tokens on 401 auth errors.

Calamari commented 3 years ago

Well, it does not way for me :) It sadly seems like this project is kind-of dead/unmaintend right now. The last commits where a year ago. Sadly, nothing is happening.