/
axios_v0.16.x.js
120 lines (116 loc) · 4.15 KB
/
axios_v0.16.x.js
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// flow-typed signature: b371e1002f7439f9f053dc08186c5375
// flow-typed version: dbaff82b4f/axios_v0.16.x/flow_>=v0.28.x
declare module 'axios' {
declare interface ProxyConfig {
host: string;
port: number;
}
declare interface Cancel {
constructor(message?: string): Cancel;
message: string;
}
declare interface Canceler {
(message?: string): void;
}
declare interface CancelTokenSource {
token: CancelToken;
cancel: Canceler;
}
declare interface CancelToken {
constructor(executor: (cancel: Canceler) => void): CancelToken;
static source(): CancelTokenSource;
promise: Promise<Cancel>;
reason?: Cancel;
throwIfRequested(): void;
}
declare interface AxiosXHRConfigBase<T> {
adapter?: <T>(config: AxiosXHRConfig<T>) => Promise<AxiosXHR<T>>;
auth?: {
username: string,
password: string
};
baseURL?: string,
cancelToken?: CancelToken;
headers?: Object;
httpAgent?: mixed; // Missing the type in the core flow node libdef
httpsAgent?: mixed; // Missing the type in the core flow node libdef
maxContentLength?: number;
maxRedirects?: 5,
params?: Object;
paramsSerializer?: (params: Object) => string;
progress?: (progressEvent: Event) => void | mixed;
proxy?: ProxyConfig;
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
timeout?: number;
transformRequest?: Array<<U>(data: T) => U|Array<<U>(data: T) => U>>;
transformResponse?: Array<<U>(data: T) => U>;
validateStatus?: (status: number) => boolean,
withCredentials?: boolean;
xsrfCookieName?: string;
xsrfHeaderName?: string;
}
declare type $AxiosXHRConfigBase<T> = AxiosXHRConfigBase<T>;
declare interface AxiosXHRConfig<T> extends AxiosXHRConfigBase<T> {
data?: T;
method?: string;
url: string;
}
declare type $AxiosXHRConfig<T> = AxiosXHRConfig<T>;
declare class AxiosXHR<T> {
config: AxiosXHRConfig<T>;
data: T;
headers: Object;
status: number;
statusText: string,
request: http$ClientRequest | XMLHttpRequest
}
declare type $AxiosXHR<T> = $AxiosXHR<T>;
declare class AxiosInterceptorIdent extends String {}
declare class AxiosRequestInterceptor<T> {
use(
successHandler: ?(response: AxiosXHRConfig<T>) => Promise<AxiosXHRConfig<*>> | AxiosXHRConfig<*>,
errorHandler: ?(error: mixed) => mixed,
): AxiosInterceptorIdent;
eject(ident: AxiosInterceptorIdent): void;
}
declare class AxiosResponseInterceptor<T> {
use(
successHandler: ?(response: AxiosXHR<T>) => mixed,
errorHandler: ?(error: mixed) => mixed,
): AxiosInterceptorIdent;
eject(ident: AxiosInterceptorIdent): void;
}
declare type AxiosPromise<T> = Promise<AxiosXHR<T>>;
declare class Axios {
constructor<T>(config?: AxiosXHRConfigBase<T>): void;
$call: <T>(config: AxiosXHRConfig<T> | string, config?: AxiosXHRConfig<T>) => AxiosPromise<T>;
request<T>(config: AxiosXHRConfig<T>): AxiosPromise<T>;
delete<T>(url: string, config?: AxiosXHRConfigBase<T>): AxiosPromise<T>;
get<T>(url: string, config?: AxiosXHRConfigBase<T>): AxiosPromise<T>;
head<T>(url: string, config?: AxiosXHRConfigBase<T>): AxiosPromise<T>;
post<T>(url: string, data?: mixed, config?: AxiosXHRConfigBase<T>): AxiosPromise<T>;
put<T>(url: string, data?: mixed, config?: AxiosXHRConfigBase<T>): AxiosPromise<T>;
patch<T>(url: string, data?: mixed, config?: AxiosXHRConfigBase<T>): AxiosPromise<T>;
interceptors: {
request: AxiosRequestInterceptor<mixed>,
response: AxiosResponseInterceptor<mixed>,
};
defaults: AxiosXHRConfig<*> & { headers: Object };
}
declare class AxiosError<T> extends Error {
config: AxiosXHRConfig<T>;
response: AxiosXHR<T>;
code?: string;
}
declare type $AxiosError<T> = AxiosError<T>;
declare interface AxiosExport extends Axios {
Axios: typeof Axios;
Cancel: Class<Cancel>;
CancelToken: Class<CancelToken>;
isCancel(value: any): boolean;
create(config?: AxiosXHRConfigBase<any>): Axios;
all: typeof Promise.all;
spread(callback: Function): (arr: Array<any>) => Function
}
declare module.exports: AxiosExport;
}