@@ -6,6 +6,14 @@ type MethodsHeaders = {
6
6
[ Key in Method as Lowercase < Key > ] : AxiosHeaders ;
7
7
} ;
8
8
9
+ type FetchOptions = object ;
10
+
11
+ type FetchURL = URL ;
12
+
13
+ type FetchRequest = Request ;
14
+
15
+ type FetchInput = FetchURL | FetchRequest | string ;
16
+
9
17
interface CommonHeaders {
10
18
common : AxiosHeaders ;
11
19
}
@@ -279,12 +287,15 @@ export interface AxiosProgressEvent {
279
287
280
288
type Milliseconds = number ;
281
289
282
- type AxiosAdapterName = 'xhr' | 'http' | string ;
290
+ type AxiosAdapterName = 'fetch' | ' xhr' | 'http' | string ;
283
291
284
292
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName ;
285
293
294
+ type Fetcher = ( input : FetchInput , init ?: FetchOptions ) => Promise < Response > ;
295
+
286
296
export interface AxiosRequestConfig < D = any > {
287
- url ?: string ;
297
+ url ?: string | FetchURL ;
298
+ parsedUrl ?: FetchURL ;
288
299
method ?: Method | string ;
289
300
baseURL ?: string ;
290
301
transformRequest ?: AxiosRequestTransformer | AxiosRequestTransformer [ ] ;
@@ -297,6 +308,8 @@ export interface AxiosRequestConfig<D = any> {
297
308
timeoutErrorMessage ?: string ;
298
309
withCredentials ?: boolean ;
299
310
adapter ?: AxiosAdapterConfig | AxiosAdapterConfig [ ] ;
311
+ fetcher ?: Fetcher ;
312
+ fetchOptions ?: FetchOptions ;
300
313
auth ?: AxiosBasicCredentials ;
301
314
responseType ?: ResponseType ;
302
315
responseEncoding ?: responseEncoding | string ;
@@ -439,6 +452,8 @@ export interface AxiosInterceptorManager<V> {
439
452
clear ( ) : void ;
440
453
}
441
454
455
+ type AxiosRequestFetchInputs = FetchURL | FetchRequest | string ;
456
+
442
457
export class Axios {
443
458
constructor ( config ?: AxiosRequestConfig ) ;
444
459
defaults : AxiosDefaults ;
@@ -447,17 +462,17 @@ export class Axios {
447
462
response : AxiosInterceptorManager < AxiosResponse > ;
448
463
} ;
449
464
getUri ( config ?: AxiosRequestConfig ) : string ;
450
- request < T = any , R = AxiosResponse < T > , D = any > ( config : AxiosRequestConfig < D > ) : Promise < R > ;
451
- get < T = any , R = AxiosResponse < T > , D = any > ( url : string , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
452
- delete < T = any , R = AxiosResponse < T > , D = any > ( url : string , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
453
- head < T = any , R = AxiosResponse < T > , D = any > ( url : string , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
454
- options < T = any , R = AxiosResponse < T > , D = any > ( url : string , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
455
- post < T = any , R = AxiosResponse < T > , D = any > ( url : string , data ?: D , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
456
- put < T = any , R = AxiosResponse < T > , D = any > ( url : string , data ?: D , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
457
- patch < T = any , R = AxiosResponse < T > , D = any > ( url : string , data ?: D , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
458
- postForm < T = any , R = AxiosResponse < T > , D = any > ( url : string , data ?: D , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
459
- putForm < T = any , R = AxiosResponse < T > , D = any > ( url : string , data ?: D , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
460
- patchForm < T = any , R = AxiosResponse < T > , D = any > ( url : string , data ?: D , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
465
+ request < T = any , R = AxiosResponse < T > , D = any > ( config : AxiosRequestConfig < D > | AxiosRequestFetchInputs ) : Promise < R > ;
466
+ get < T = any , R = AxiosResponse < T > , D = any > ( url : AxiosRequestFetchInputs , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
467
+ delete < T = any , R = AxiosResponse < T > , D = any > ( url : AxiosRequestFetchInputs , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
468
+ head < T = any , R = AxiosResponse < T > , D = any > ( url : AxiosRequestFetchInputs , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
469
+ options < T = any , R = AxiosResponse < T > , D = any > ( url : AxiosRequestFetchInputs , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
470
+ post < T = any , R = AxiosResponse < T > , D = any > ( url : AxiosRequestFetchInputs , data ?: D , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
471
+ put < T = any , R = AxiosResponse < T > , D = any > ( url : AxiosRequestFetchInputs , data ?: D , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
472
+ patch < T = any , R = AxiosResponse < T > , D = any > ( url : AxiosRequestFetchInputs , data ?: D , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
473
+ postForm < T = any , R = AxiosResponse < T > , D = any > ( url : AxiosRequestFetchInputs , data ?: D , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
474
+ putForm < T = any , R = AxiosResponse < T > , D = any > ( url : AxiosRequestFetchInputs , data ?: D , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
475
+ patchForm < T = any , R = AxiosResponse < T > , D = any > ( url : AxiosRequestFetchInputs , data ?: D , config ?: AxiosRequestConfig < D > ) : Promise < R > ;
461
476
}
462
477
463
478
export interface AxiosInstance extends Axios {
@@ -494,7 +509,7 @@ export function isCancel(value: any): value is Cancel;
494
509
export function all < T > ( values : Array < T | Promise < T > > ) : Promise < T [ ] > ;
495
510
496
511
export interface AxiosStatic extends AxiosInstance {
497
- create ( config ?: CreateAxiosDefaults ) : AxiosInstance ;
512
+ create ( configOrUrlOrRequest ?: CreateAxiosDefaults | AxiosRequestFetchInputs , config ?: CreateAxiosDefaults ) : AxiosInstance ;
498
513
Cancel : CancelStatic ;
499
514
CancelToken : CancelTokenStatic ;
500
515
Axios : typeof Axios ;
0 commit comments