xior
Version:
A lite http request lib based on fetch with plugins support and similar API to axios.
26 lines (23 loc) • 1.02 kB
text/typescript
import { c as XiorInterceptorRequestConfig, k as XiorError, a as XiorRequestConfig, e as XiorPlugin } from '../xior-D4BXsC0R.mjs';
type ErrorRetryOptions = {
/** retry times, default: 2 */
retryTimes?: number;
/**
* Retry after milliseconds, default: 3000
* after first time error retry, retry interval
*/
retryInterval?: number | ((count: number, config: XiorInterceptorRequestConfig, error: XiorError) => number);
/**
* default: true,
* it's useful because we don't want retry when the error because of token expired
*/
enableRetry?: boolean | ((config: XiorRequestConfig, error: XiorError) => boolean | undefined);
onRetry?: (config: XiorRequestConfig, error: XiorError, count: number) => void;
};
/** @ts-ignore */
declare module 'xior' {
interface XiorRequestConfig extends ErrorRetryOptions {
}
}
declare function xiorErrorRetryPlugin(options?: ErrorRetryOptions): XiorPlugin;
export { type ErrorRetryOptions, xiorErrorRetryPlugin as default };