JustinBeckwith/retry-axios

Add option to return first error instead of last one

Opened this issue · 0 comments

Sometimes, you may want to retry unsafe reqests, e.g. POST.
But in this case, it's better to return the first error instead of the last one, otherwise the root cause might be lost.

Example: Our POST API calls another API, and then does something internally.

  • 1st try: Calling other API succeeds, and our stuff fails
  • 2nd try (retried by this library): Calling other API fails now because preconditions are no longer fulfilled.

Currently when using axiosInstance.post with this library, we get the 2nd error instead of the 1st one.
That's bad, since it now appears as if the root cause was calling the external API, but the error was actually in our code.

Is there maybe already a workaround to get this behavior?