kuitos / axios-extensions

🍱 axios extensions lib, including throttle, cache, retry features etc...
MIT License
831 stars 49 forks source link

Getting error while using useCache flag #58

Closed sunilsharma2214 closed 4 years ago

sunilsharma2214 commented 5 years ago

axios.ts file const axiosAppInstance = axios.create({ // @ts-ignore adapter: cacheAdapterEnhancer(axios.defaults.adapter, { enabledByDefault: false, cacheFlag: 'useCache'}), baseURL: appConfig.getRequired('abc'), });

abc.ts file axiosAppInstance.get('xyz',{ useCache: true }),

TypeScript error Argument of type '{ useCache: boolean; }' is not assignable to parameter of type 'AxiosRequestConfig'. Object literal may only specify known properties, and 'useCache' does not exist in type 'AxiosRequestConfig'.ts

CKGrafico commented 5 years ago

You need the typing

declare module 'axios' {
  interface AxiosRequestConfig {
    cache?: boolean;
  }
}
kuitos commented 4 years ago

here is the solution https://github.com/kuitos/axios-extensions#custom-cache-typing

adbutterfield commented 4 years ago

I try not to comment on closed issues but... I'm getting:

node_modules/axios-extensions/esm"' has no exported member 'ICacheLike'

using the solution above.

adbutterfield commented 4 years ago

Oh, I guess the change not released yet.

kuitos commented 4 years ago

released v3.1.2, thanks for your feedback~