arthurfiorette / axios-cache-interceptor

📬 Small and efficient cache interceptor for axios. Etag, Cache-Control, TTL, HTTP headers and more!
https://axios-cache-interceptor.js.org
MIT License
703 stars 58 forks source link

Bug: Are docs wrong for v0 version? #870

Closed Nisthar closed 3 months ago

Nisthar commented 3 months ago

What happened?

Docs says to use setupCache from 'axios-cache-interceptor' but there is no setupCache export in v0. is this a typo ?

import { setupCache } from 'axios-cache-interceptor';

const axios = setupCache(Axios);

axios-cache-interceptor version

v0.2

Node / Browser Version

18

Axios Version

0.21

What storage is being used

Memory Storage

Relevant debugging log output

setupCache is undefined.
arthurfiorette commented 3 months ago

Axios Cache Interceptor v0 does exports setup cache.

pnpm i axios-cache-interceptor@0
node -e "console.log(require('axios-cache-interceptor'))"

outputs:

Object [Module] {
  Header: [Getter],
  buildKeyGenerator: [Getter],
  buildMemoryStorage: [Getter],
  buildStorage: [Getter],
  buildWebStorage: [Getter],
  canStale: [Getter],
  createCacheResponse: [Getter],
  createValidateStatus: [Getter],
  defaultHeaderInterpreter: [Getter],
  defaultKeyGenerator: [Getter],
  defaultRequestInterceptor: [Getter],
  defaultResponseInterceptor: [Getter],
  isExpired: [Getter],
  isMethodIn: [Getter],
  isStorage: [Getter],
  setupCache: [Getter], // <---- HERE
  testCachePredicate: [Getter],
  updateCache: [Getter],
  updateStaleRequest: [Getter]
}
Nisthar commented 3 months ago

@arthurfiorette This is what i get. I am using version ^0.2.8 since my axios version is 0.21.1

{
  StatusCodes: {
    CACHED_STATUS_CODE: 304,
    CACHED_STATUS_TEXT: '304 Cached by axios-cache-interceptor'
  },
  applyCache: [Getter],
  createCache: [Getter]
}
arthurfiorette commented 3 months ago

Oh, you are using a version from 3 years ago. This version is obviously not supported anymore, I'm pretty sure axios 0.21.1 is also not supported as well.

For obviously reasons the documentation for v1 only covers the latest v1 releases and docs for v0 only covers the latest v0 release.

arthurfiorette commented 3 months ago

The package has a README bundled with the source code inside your node_modules, you can read it.