axios-extensions
axios-extensions copied to clipboard
axios 1.x has changed axios.defaults.adapter
can't use getDefaultAdapter with axios 1.x
https://github.com/axios/axios/commit/d032edda08948f3f613ff34f32af49cad3aa74db
Maybe we should release 4.x version for this breaking change
Maybe we should release 4.x version for this breaking change
It would be great !
Is there a temporal workaround for this ?
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);
}
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.
const defaultAdapter = axios.getAdapter('http');
or
const defaultAdapter = axios.getAdapter(axios.defaults.adapter);
works for me
Maybe we should release 4.x version for this breaking change也许我们应该为这个突破性的变化发布4.x版本
Any progress on the new project?