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

axios 1.x has changed axios.defaults.adapter #103

Open
zhenghangjie opened this issue Jun 14, 2023 · 7 comments
Open

axios 1.x has changed axios.defaults.adapter #103

zhenghangjie opened this issue Jun 14, 2023 · 7 comments

Comments

@zhenghangjie
Copy link

can't use getDefaultAdapter with axios 1.x

axios/axios@d032edd

@kuitos
Copy link
Owner

kuitos commented Jun 16, 2023

Maybe we should release 4.x version for this breaking change

@nabenzine
Copy link

Maybe we should release 4.x version for this breaking change

It would be great !

@bilby91
Copy link

bilby91 commented Jul 6, 2023

Is there a temporal workaround for this ?

@shrpne
Copy link

shrpne commented Jul 18, 2023

This works for me

import axios from 'axios';
import adapters from 'axios/lib/adapters/adapters.js';

const getAdapter = adapters.getAdapter;

/**
 * @return {import('axios').AxiosAdapter}
 */
export function getDefaultAdapter() {
    return getAdapter(axios.defaults.adapter);
}

@BryceBarbara
Copy link

As it stands, there doesn't seem to be a valid typescript safe way to do this without some hand waving. It doesn't appear the axios library types any of its adapter files and doesn't provide a type-safe way of accessing them.

@simllll
Copy link

simllll commented Oct 24, 2023

const defaultAdapter = axios.getAdapter('http');
or
const defaultAdapter = axios.getAdapter(axios.defaults.adapter);
works for me

@litchia
Copy link

litchia commented Nov 17, 2023

Maybe we should release 4.x version for this breaking change也许我们应该为这个突破性的变化发布4.x版本

Any progress on the new project?

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

No branches or pull requests

8 participants