retrofit-axios-ts
Version:
A declarative and axios based retrofit implementation for JavaScript and TypeScript.
16 lines (15 loc) • 819 B
TypeScript
import { AxiosResponse, InternalAxiosRequestConfig } from "axios";
export type LogCallback = (config: RequestConfig, response: Response) => void;
export type RequestConfig = InternalAxiosRequestConfig;
export interface Response<T = any> extends AxiosResponse<T> {
}
export interface RequestInterceptors {
fulfilled?: (config: RequestConfig) => RequestConfig | Promise<RequestConfig>;
rejected?: (error: any) => any;
}
export interface ResponseInterceptors {
fulfilled?: <T>(response: Response<T>) => Response<T> | Promise<Response<T>>;
rejected?: (error: any) => any;
}
export type RequestInterceptorFunction = (value: RequestConfig) => RequestConfig | Promise<RequestConfig>;
export type ResponseInterceptorFunction<T = any> = (value: Response<T>) => Response<T> | Promise<Response<T>>;