UNPKG

axios-retryer

Version:

axios-retryer is an advanced Axios request manager offering intelligent retry logic with token refresh, concurrency control, priority queuing, and a flexible plugin architecture, all built with TypeScript for robust HTTP client integrations.

34 lines (33 loc) 1.24 kB
export { TokenRefreshPlugin } from './TokenRefreshPlugin'; export type { TokenRefreshPluginOptions } from './types'; import { TokenRefreshPlugin } from './TokenRefreshPlugin'; import type { TokenRefreshPluginOptions } from './types'; import type { AxiosInstance } from 'axios'; /** * Creates a TokenRefreshPlugin instance. * Functional alternative to using the `new TokenRefreshPlugin()` constructor. * * @param refreshToken Function that performs the token refresh operation * @param options Configuration options for the TokenRefreshPlugin * @returns A configured TokenRefreshPlugin instance * * @example * ```typescript * const tokenRefresher = createTokenRefreshPlugin( * async (axiosInstance) => { * const refreshToken = localStorage.getItem('refreshToken'); * const { data } = await axiosInstance.post('/auth/refresh', { refreshToken }); * return { token: data.accessToken }; * }, * { * authHeaderName: 'Authorization', * tokenPrefix: 'Bearer ' * } * ); * * manager.use(tokenRefresher); * ``` */ export declare function createTokenRefreshPlugin(refreshToken: (axiosInst: AxiosInstance) => Promise<{ token: string; }>, options?: TokenRefreshPluginOptions): TokenRefreshPlugin;