Skip to content

Commit

Permalink
fix: interpretHeader name conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurfiorette committed Sep 11, 2021
1 parent aa0f90e commit 0d4854d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/axios/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import CacheInstance, { AxiosCacheInstance, CacheProperties } from './types';

export function createCache(
axios: AxiosInstance,
options: Partial<CacheInstance & CacheProperties> = {}
options: Partial<CacheInstance> & Partial<CacheProperties> = {}
): AxiosCacheInstance {
const axiosCache = axios as AxiosCacheInstance;

axiosCache.storage = options.storage || new MemoryStorage();
axiosCache.generateKey = options.generateKey || defaultKeyGenerator;
axiosCache.waiting = options.waiting || {};
axiosCache.interpretHeader = options.interpretHeader || defaultHeaderInterpreter;
axiosCache.headerInterpreter = options.headerInterpreter || defaultHeaderInterpreter;

// CacheRequestConfig values
axiosCache.defaults = {
Expand Down
2 changes: 1 addition & 1 deletion src/axios/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default interface CacheInstance {
* The function to parse and interpret response headers.
* Only used if cache.interpretHeader is true.
*/
interpretHeader: HeaderInterpreter;
headerInterpreter: HeaderInterpreter;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/interceptors/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function applyResponseInterceptor(axios: AxiosCacheInstance): void {
let saveCache = true;

if (response.config.cache?.interpretHeader) {
const expirationTime = axios.interpretHeader(response.headers['cache-control']);
const expirationTime = axios.headerInterpreter(response.headers['cache-control']);

// Header told that this response should not be cached.
if (expirationTime === false) {
Expand Down

0 comments on commit 0d4854d

Please sign in to comment.