Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting error while using useCache flag #58

Closed
sunilsharma2214 opened this issue Sep 26, 2019 · 5 comments · Fixed by #69
Closed

Getting error while using useCache flag #58

sunilsharma2214 opened this issue Sep 26, 2019 · 5 comments · Fixed by #69

Comments

@sunilsharma2214
Copy link

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
Copy link

You need the typing

declare module 'axios' {
  interface AxiosRequestConfig {
    cache?: boolean;
  }
}

@kuitos
Copy link
Owner

kuitos commented Feb 20, 2020

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

@adbutterfield
Copy link

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
Copy link

Oh, I guess the change not released yet.

@kuitos
Copy link
Owner

kuitos commented Mar 5, 2020

released v3.1.2, thanks for your feedback~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants