support for mocks when an interceptor retries a request #119
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I found that if I have an interceptor that was attempting to retry a request (perhaps an interceptor that checks for 401 response codes, then requests a new oauth2 token, then retries the request) it wouldn't use the mock adapter for the retried attempts. I found that in the handle request, we setting the adapter to null. Instead we should actually delete the adapter so axios will use the instance default one.
Looks like this is also the same scenario as issue #68. Essentially any time we tried to retry a request in an interceptor using the same config, it was bypassing the mock adapter and making a real request which is why in Issue #68 they were seeing it give a 404 response code back.