diff --git a/index.d.ts b/index.d.ts index e059b32c..0dc34fe9 100644 --- a/index.d.ts +++ b/index.d.ts @@ -724,6 +724,8 @@ export function mergeConfig( config2: AxiosRequestConfig ): AxiosRequestConfig; +export function create(config?: CreateAxiosDefaults): AxiosInstance; + export interface AxiosStatic extends AxiosInstance { Cancel: CancelStatic; CancelToken: CancelTokenStatic; diff --git a/index.js b/index.js index 7dbe23b9..5bc03654 100644 --- a/index.js +++ b/index.js @@ -20,10 +20,12 @@ const { formToJSON, getAdapter, mergeConfig, + create, } = axios; export { axios as default, + create, Axios, AxiosError, CanceledError, diff --git a/tests/unit/api.test.js b/tests/unit/api.test.js index 992b307b..d84aa0d5 100644 --- a/tests/unit/api.test.js +++ b/tests/unit/api.test.js @@ -1,6 +1,6 @@ import { describe, it } from 'vitest'; import assert from 'assert'; -import axios from '../../index.js'; +import axios, { create } from '../../index.js'; describe('static api', () => { it('should have request method helpers', () => { @@ -53,6 +53,11 @@ describe('static api', () => { assert.strictEqual(typeof axios.create, 'function'); }); + it('should expose create as a named export', () => { + assert.strictEqual(typeof create, 'function'); + assert.strictEqual(create, axios.create); + }); + it('should have CanceledError, CancelToken, and isCancel properties', () => { assert.strictEqual(typeof axios.Cancel, 'function'); assert.strictEqual(typeof axios.CancelToken, 'function');