diff --git a/src/axios/cache.ts b/src/axios/cache.ts index c70c8a4..a281db6 100644 --- a/src/axios/cache.ts +++ b/src/axios/cache.ts @@ -61,13 +61,17 @@ export function applyCache( /** * Returns a new axios instance with caching enabled. * - * @param config The config for the caching interceptors - * @param axiosConfig The config for the created axios instance - * @returns The same instance but with caching enabled + * @param config The config for the caching interceptors and the axios instance + * @returns A new AxiosCacheInstance with caching enabled */ -export function createCache( - config: Partial & Partial = {}, - axiosConfig: AxiosRequestConfig = {} -): AxiosCacheInstance { - return applyCache(Axios.create(axiosConfig), config); +export function createCache({ + axios = {}, + cache = {} +}: CreateCacheOptions = {}): AxiosCacheInstance { + return applyCache(Axios.create(axios), cache); } + +export type CreateCacheOptions = { + axios?: Partial; + cache?: Partial & Partial; +}; diff --git a/test/mocks/axios.ts b/test/mocks/axios.ts index d36f8b1..621ab8e 100644 --- a/test/mocks/axios.ts +++ b/test/mocks/axios.ts @@ -11,8 +11,7 @@ export function mockAxios( headers: Record = {} ): AxiosCacheInstance { const axios = createCache({ - // Defaults to cache every request - ...options + cache: options }); // Axios interceptors are a stack, so apply this after the cache interceptor