Skip to content

Commit

Permalink
feat!: removed createCache function
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurfiorette committed Dec 8, 2021
1 parent 704be77 commit 60ad91e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 30 deletions.
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,6 @@ axios = useCache(axios, {
});
```

or by creating a new one:

```js
import { createCache } from 'axios-cache-interceptor';

const axios = createCache({
/* options here */
});
```

After that, you can made your own requests normally.

<br />
Expand Down Expand Up @@ -258,7 +248,7 @@ the internal code. Remember that, depending on the
When applying the interceptor, you can customize some properties:

```js
const axios = createCache({
const axios = useCache(axios, {
// Properties here
});
```
Expand Down
20 changes: 1 addition & 19 deletions src/cache/create.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
import type { AxiosInstance } from 'axios';
import { defaultHeaderInterpreter } from '../header/interpreter';
import { CacheRequestInterceptor } from '../interceptors/request';
import { CacheResponseInterceptor } from '../interceptors/response';
Expand Down Expand Up @@ -59,22 +59,4 @@ export function useCache(
return axiosCache;
}

/**
* Returns a new axios instance 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({
axios,
cache
}: CreateCacheOptions = {}): AxiosCacheInstance {
return useCache(Axios.create(axios), cache);
}

export type CacheOptions = Partial<CacheInstance> & Partial<CacheProperties>;

export type CreateCacheOptions = {
axios?: Partial<AxiosRequestConfig>;
cache?: CacheOptions;
};

0 comments on commit 60ad91e

Please sign in to comment.