Skip to content
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

getAdapter method should became public to let adapters like axios-mock-adapter access http / xhr known adapters #5474

Closed
paztis opened this issue Jan 17, 2023 · 2 comments · Fixed by #5324 · May be fixed by #5540
Closed

Comments

@paztis
Copy link

paztis commented Jan 17, 2023

Describe the bug

libraries like axios-mock-adapter define an adapter but in same cases need to access to original adapter.

It was working correctly before as the adapter was always a function.
Now it can be an array of string

Only the method getAdapter() in adapters/adapter.js can allow access to original adapters (xhr and http)
But this method is not exported a all at top level.

Can you export it ?

To Reproduce

Try to use axios-mock-adapter plugin with onNoMatch option

Code snippet

No response

Expected behavior

No response

Axios Version

1.2.1 and upper

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

No response

OS

No response

Additional Library Versions

No response

Additional context/Screenshots

No response

@mogzol
Copy link

mogzol commented Jan 21, 2023

I would also appreciate this. I have a custom adapter that wraps the default one, but it is unusable with the latest axios releases due to it being impossible to access the default adapters.

@unional
Copy link

unional commented Feb 10, 2023

The http adapter is also needed to workaround an issue for jsdom: https://stackoverflow.com/questions/51054286/cross-origin-http-request-originating-from-server-side-nodejs-axios-jsdom

Currently it is not exposed and with exports field we can't even force our way in using declare module 'axios/lib/adapters/http' for TypeScript.

UPDATE: that issue can be fixed by axios.defaults.adapter = 'http'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants