UNPKG

axios-refresh-me

Version:

Axios wrapper for refresh token and retry request

46 lines (42 loc) 1.57 kB
import { InternalAxiosRequestConfig, AxiosError, CreateAxiosDefaults, AxiosResponse, AxiosInstance } from 'axios'; type CustomConfig = InternalAxiosRequestConfig & { _retryCount?: number; }; type RequestObserverOptions = { refreshHandler: () => Promise<void>; combineAbortSignals?: boolean; statusCodes?: number[]; retryCount?: number; shouldRefresh?: (error: AxiosError) => boolean; }; interface AxiosClientInterceptors { request?: { onFulfilled?: (config: CustomConfig) => CustomConfig; onRejected?: (error: AxiosError) => any | void; }; response?: { onFulfilled?: (response: AxiosResponse) => AxiosResponse; onRejected?: (error: AxiosError) => any | void; }; } interface AxiosClientContructor extends CreateAxiosDefaults { interceptors?: AxiosClientInterceptors; } declare class AxiosInstanceFactory { private static observer; private static internalInterceptor; private constructor(); private static useInterceptorReq; private static useInterceptorRes; static interceptor: { request: { use: (onFulfilled: (config: CustomConfig) => CustomConfig, onRejected?: (error: AxiosError) => any) => void; }; response: { use: (onFulfilled: (response: AxiosResponse) => AxiosResponse, onRejected?: (error: AxiosError) => any) => void; }; }; static use(config: RequestObserverOptions): void; static getInstance(config: AxiosClientContructor): AxiosInstance; } export { AxiosInstanceFactory as default };