fix: interpretHeader name conflict

This commit is contained in:
Hazork 2021-09-11 13:03:35 -03:00
parent aa0f90ed77
commit 0d4854db83
3 changed files with 4 additions and 4 deletions

View File

@ -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 = {

View File

@ -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;
}
/**

View File

@ -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) {