axios-extensions icon indicating copy to clipboard operation
axios-extensions copied to clipboard

axios 1.x has changed axios.defaults.adapter

Open defaultjacky opened this issue 2 years ago • 7 comments

can't use getDefaultAdapter with axios 1.x

https://github.com/axios/axios/commit/d032edda08948f3f613ff34f32af49cad3aa74db

defaultjacky avatar Jun 14 '23 12:06 defaultjacky

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

kuitos avatar Jun 16 '23 07:06 kuitos

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

It would be great !

nabenzine avatar Jun 28 '23 19:06 nabenzine

Is there a temporal workaround for this ?

bilby91 avatar Jul 06 '23 21:07 bilby91

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);
}

shrpne avatar Jul 18 '23 14:07 shrpne

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.

BryceBarbara avatar Jul 31 '23 23:07 BryceBarbara

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

simllll avatar Oct 24 '23 08:10 simllll

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

Any progress on the new project?

litchia avatar Nov 17 '23 08:11 litchia