UNPKG

@ovine/core

Version:

Build flexible admin system with json.

32 lines (31 loc) 1.28 kB
/** * 封装 fetch 请求 * TODO: 请求模块需要 编写测试用例 */ import * as Types from "./types"; export declare function normalizeUrl(urlStr: string, defMethod?: string): { url: string; method: Types.ReqMethod; }; export declare function getUrlByOption(this: Types.ReqConfig, option: Types.ReqOption & Partial<Types.ReqConfig>): { url: string; method: Types.ReqMethod | undefined; }; export declare class Request<IS = {}, IP = {}> { constructor(config?: Types.ReqConfig); domains: { [domain: string]: string; }; isMock?: boolean; onPreRequest?: (option: Types.ReqOption) => Types.ReqOption; onRequest?: (option: Types.ReqOption) => Types.ReqOption; onError?: (response: Types.ReqResponse, option: Types.ReqOption, error: Error) => void; onSuccess?: (source: any, option: Types.ReqOption, response: Types.ReqResponse) => any; onFinish?: (response: Types.ReqResponse, option: Types.ReqOption, error?: Error) => void; setConfig(config?: Types.ReqConfig): void; getUrlByOption(option: Types.ReqOption<IS, IP>): { url: string; method: Types.ReqMethod | undefined; }; request<S = {}, P = {}>(option: Types.ReqOption<S | IS, P | IP>): Promise<Types.ReqResponse<S | IS> | undefined>; }