Skip to content

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

Closed

Description

@paztis

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

Activity

  1. mogzol commented on Jan 21, 2023

    @mogzol

    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.

  2. unional commented on Feb 10, 2023

    @unional

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions