-
Notifications
You must be signed in to change notification settings - Fork 247
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
passthrough onNoMatch does not work with axios 1.2.0 or above #357
Comments
Hi! I am experimenting this Issue with the package. Is there a workaround while still using the library? For now I downgraded axios to 1.1.3 and its functional. |
@nicolascampbell The only workaround I'm aware of is to stay below axios v1.2.0 (the release v1.2.0-alpha.1 should also work though) if you still want to be able to passthrough requests. |
I've create this issue in axios: axios/axios#5474 by waiting this you can at least manage the support of the array internally, or temporary do an import of axios/lib/adapters/adapter.js to access getAdapter method |
A fix for this module is in #363 |
hello @marcbachmann any update on the fix? :) |
Sadly not yet. The PR is ready to merge |
@marcbachmann Today I discovered that I will now revisit my workaround in my library and fix it properly. |
I maintain axios-response-mock which covers a similar use-case as does
axios-mock-adapter
.My lib broke with axios version 1.2.0 with regard to passthrough requests; I got runtime errors in the vein of 'originalAdapter is not a function'.
I finished analysing the issue and thought I let you know what I found out; because I'm quite sure it broke your lib in the very same way.
The following section contains my analysis and thoughts.
Analysis
['xhr', 'http']
the change was introduced with
#5277
(Changelog entry:
refactor: allowing adapters to be loaded by name #5277
)(merged November 22nd) and released with v1.2.0 on November 22nd
If a custom adapter now wants to selectively decide which requests to handle itself and which requests to passthrough to the default adapter / delegate to the default adapter, how best would it now obtain a reference to the default adapter?
Before the change, a custom adapter could secure a reference to the default adapter via
axiosInstance.defaults.adapter
and call it later to delegate.Example:
I opened a discussion on the axios github repo.
What options do I have now?
Conclusion:
Today I published version 0.2.2-alpha.1 of
axios-response-mock
and it seems I could fix the issue. But it is only a temporary stopgap.When axios starts supporting a stable way to obtain a reference to the defaultAdapter I will change my fix; if the axios maintainers dismiss the feature request I will probably refactor my lib into the two steps approach sketched above.
The text was updated successfully, but these errors were encountered: