forked from hatedMe/wechat-request
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
56 lines (47 loc) · 1.75 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
export interface BaseData {
[key: string]: any;
}
export interface RequestPromise<T = any> extends Promise<Response<T>> {
}
export interface RequestConfig {
url?: string ;
method?: Method ;
baseURL?: string ;
headers? : BaseData;
params? : BaseData;
timeout? : number;
}
export interface InterceptorManager<V> {
use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number;
eject(id: number): void;
}
export interface Response<T = BaseData> {
data : T ,
status : number ,
statusText : string ,
headers : T ,
config : RequestConfig
}
export interface RequestError<T = any> extends Error {
}
export interface Instance {
(config: RequestConfig): RequestPromise;
(url: string, config?: RequestConfig): RequestPromise;
interceptors: {
request: InterceptorManager<RequestConfig>;
response: InterceptorManager<Response>;
};
request<T = any, R = Response<T>> (config: RequestConfig): Promise<R>;
get<T = any, R = Response<T>>(url: string, config?: RequestConfig): Promise<R>;
delete<T = any, R = Response<T>>(url: string, config?: RequestConfig): Promise<R>;
head<T = any, R = Response<T>>(url: string, config?: RequestConfig): Promise<R>;
post<T = any, R = Response<T>>(url: string, data?: any, config?: RequestConfig): Promise<R>;
put<T = any, R = Response<T>>(url: string, data?: any, config?: RequestConfig): Promise<R>;
patch<T = any, R = Response<T>>(url: string, data?: any, config?: RequestConfig): Promise<R>;
}
export interface RequestStatic extends Instance {
create(config?: RequestConfig): Instance;
all<T>(values: (T | Promise<T>)[]): Promise<T[]>;
}
declare const wechatRequest : RequestStatic
export default wechatRequest;