alloy-request
Version:
alloy-request 基于`axios`和`ahooks的useRequest`封装的 react 请求库
28 lines (27 loc) • 1.25 kB
TypeScript
import { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
type TypeAipResponse = {
code?: number;
data?: any;
[key: string]: any;
};
type TFormatter = {
getUrl?: (url: string) => string;
};
type TInstance = {
request?: (req: AxiosRequestConfig) => AxiosRequestConfig;
response?: (res: AxiosResponse) => AxiosResponse;
error?: (error: AxiosError) => AxiosError;
};
export declare function initInstance({ request, response, error, getUrl }: TInstance & TFormatter): void;
/**
* @param {string} url
* @param {*} [data]
* @param {*} [config]
* @returns {Promise<T>}
*/
export declare function post(url: string, data?: Record<string, any>, config?: Record<string, any>): Promise<TypeAipResponse>;
export declare function get(url: string, data?: Record<string, any>, config?: Record<string, any>): Promise<TypeAipResponse>;
export declare function put(url: string, data?: Record<string, any>, config?: Record<string, any>): Promise<TypeAipResponse>;
export declare function patch(url: string, data?: Record<string, any>, config?: Record<string, any>): Promise<TypeAipResponse>;
export declare function del(url: string, data?: Record<string, any>, config?: Record<string, any>): Promise<TypeAipResponse>;
export {};