axios-token-refresh (v1.0.10) is a lightweight Axios interceptor utility that automatically retries failed HTTP requests after a token refresh. It requires a custom refresh function and optionally configurable status codes (default 401). Ships TypeScript definitions, supports Bun >=1.2.12, and peer depends on axios >=0.21.1. Differentiates from similar libraries by minimal API surface and clear error handling.
npm install axios-token-refreshNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create an Axios instance, define a refresh token function, and register the interceptor.
Pass `statusCodes: [401, 403]` in config if needed.
Ensure `refreshRequest` returns `Promise.resolve()` or a promise from axios.post.
Upgrade Bun to >=1.2.12 or use Node.js with appropriate polyfills.
Clone request config if shared across requests.
Wrap refresh logic: if (!failedRequest.response) return Promise.reject(); then access config.
Use `import registerAxiosTokenRefresh from 'axios-token-refresh'` (no braces).
Run `npm install axios@>=0.21.1`.