Replies: 1 comment
-
Today I discovered that So delegating calls to the default adapter is now possible again.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I maintain the axios-response-mock library which provides a custom adapter to answer some requests with dummy data (and not hit the network); all unmatched requests passthrough normally (This is quite similar to -but not as popular as- axios-mock-adapter).
Version 1.2.0 of axios introduced a change
#5277
(Changelog entry:refactor: allowing adapters to be loaded by name #5277
) that makes it impossible to delegate any calls to the default adapter. Both mock libraries are affected and can no longer passthrough any requests if used with axios v1.2.0 or above.I would like to discuss how axios could allow this use-case ("delegating calls to the default adapter") in a viable, clean, and documented way to enable utility libraries like
axios-mock-adapter
andaxios-response-mock
to chain their own adapter infront of the default adapter.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:
There is a related feature request albeit it seems rather unilaterally done and without consent or discussion with the axios maintainers.
It seems others are also in need of this Gerhut/axiosist#55
Beta Was this translation helpful? Give feedback.
All reactions