lisaogren / axios-cache-adapter

Caching adapter for axios. Store request results in a configurable store to prevent unneeded network requests.
MIT License
725 stars 108 forks source link

reqConfig.adapter is not a function #272

Open TheNhatAT opened 1 year ago

TheNhatAT commented 1 year ago

I have face that issue when run axios-cache-adapter version 2.7.3. Full error message: reqConfig.adapter is not a function { stack: 'TypeError: reqConfig.adapter is not a function\n' + ' at _callee$ (C:\Users\dmx\WebstormProjects\VAR\Gamemaketplace\polka-env\gmp-backend\node_modules\axios-cache-adapter\dist\webpack:\axiosCacheAdapter\src\api.js:35:29)\n' + ' at tryCatch (C:\Users\dmx\WebstormProjects\VAR\Gamemaketplace\polka-env\gmp-backend\node_modules\axios-cache-adapter\dist\webpack:\axiosCacheAdapter\node_modules\regenerator-runtime\runtime.js:63:15)\n' + ' at Generator.invoke [as _invoke] (C:\Users\dmx\WebstormProjects\VAR\Gamemaketplace\polka-env\gmp-backend\node_modules\axios-cache-adapter\dist\webpack:\axiosCacheAdapter\node_modules\regenerator-runtime\runti me.js:293:1)\n' + ' at Generator.next (C:\Users\dmx\WebstormProjects\VAR\Gamemaketplace\polka-env\gmp-backend\node_modules\axios-cache-adapter\dist\webpack:\axiosCacheAdapter\node_modules\regenerator-runtime\runtime.js:118:1)\n' + ' at asyncGeneratorStep (C:\Users\dmx\WebstormProjects\VAR\Gamemaketplace\polka-env\gmp-backend\node_modules\axios-cache-adapter\dist\cache.node.js:4083:103)\n' + ' at _next (C:\Users\dmx\WebstormProjects\VAR\Gamemaketplace\polka-env\gmp-backend\node_modules\axios-cache-adapter\dist\cache.node.js:4085:194)\n' + ' at processTicksAndRejections (node:internal/process/task_queues:96:5)',

}

shameen commented 1 year ago

Downgrade to "axios": "1.1.x" (or 0.21 to match the version this package specifies)

i had the same problem, and it looks like it is caused by config.js setting the default adapter: https://github.com/RasCarlito/axios-cache-adapter/blob/master/src/config.js#L23

This was changed in axios v1.2+ from a function to a string or string array: https://github.com/axios/axios/commit/d032edda08948f3f613ff34f32af49cad3aa74db#diff-7aa4473ede4abd9ec099e87fec67fd57afafaf39e05d493ab4533acc38547eb8L293-R297 and the adapters themselves were moved to axios/lib/adapters/.

I couldn't find an easy workaround because axios/lib/adapters/ can't be imported (due to axios package.json exports)

arthurfiorette commented 1 year ago

Hey, axios-cache-adapter is broken for axios v1 and unmaintained since 2021.

I'm the maintainer of https://axios-cache-interceptor.js.org, you should check it out...