A utility library for Axios that adds configurable interceptors for caching, request deduplication, timestamp injection, retry on failure, and pending request queue monitoring. Version 3.0.24 is the latest stable release, with active development on GitHub. Key differentiators: built-in getKey for request identity, flexible cache with per-request control, and a simple API for attaching interceptors to any Axios instance.
npm install axios-interceptorNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to set up axios-interceptor with caching, deduplication, timestamp, retry, and queue change listener on an Axios instance.
Change import { useInterceptor } from 'axios-interceptor' (remove default import).Use const { doRetry } = useInterceptor(...) and call doRetry(config) to retry.Implement a custom getKey that extracts relevant fields (method, url, params, data).
Ensure getKey produces consistent keys for requests that should be cached.
Use import { useInterceptor } from 'axios-interceptor' (curly braces).Provide a getKey function, e.g., getKey: (config) => JSON.stringify(config).
Adjust isRetry to include 4xx if desired, e.g., isRetry: (err) => err.response?.status >= 400.