2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-30 15:24:11 +03:00

feat: export getAdapter function (#5324)

This commit is contained in:
夜葬
2023-08-27 01:42:25 +08:00
committed by GitHub
parent 9a414bb6c8
commit ca73eb878d
7 changed files with 42 additions and 0 deletions
+28
View File
@@ -16,6 +16,7 @@ import axios, {
ParamsSerializerOptions,
toFormData,
formToJSON,
getAdapter,
all,
isCancel,
isAxiosError,
@@ -570,6 +571,33 @@ axios.get('/user', {
adapter: ['xhr', 'http']
});
{
// getAdapter
getAdapter(axios.create().defaults.adapter);
getAdapter(undefined);
getAdapter([]);
getAdapter(['xhr']);
getAdapter([adapter]);
getAdapter(['xhr', 'http']);
getAdapter([adapter, 'xhr']);
getAdapter([adapter, adapter]);
getAdapter('xhr');
getAdapter(adapter);
const _: AxiosAdapter = getAdapter('xhr');
const __: AxiosAdapter = getAdapter(['xhr']);
// @ts-expect-error
getAdapter();
// @ts-expect-error
getAdapter(123);
// @ts-expect-error
getAdapter([123]);
// @ts-expect-error
getAdapter('xhr', 'http');
}
// AxiosHeaders
// iterator