mirror of
https://github.com/arthurfiorette/axios-cache-interceptor.git
synced 2025-12-08 17:36:16 +00:00
fix: interpretHeader name conflict
This commit is contained in:
parent
aa0f90ed77
commit
0d4854db83
@ -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 = {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user