mirror of
https://github.com/axios/axios.git
synced 2026-04-11 02:11:50 +08:00
fix(types): make response headers case insensative (#10677)
This commit is contained in:
parent
914bc2605a
commit
c7a76ddbf2
30
index.d.cts
30
index.d.cts
@ -39,6 +39,8 @@ type CommonResponseHeadersList =
|
|||||||
| 'Cache-Control'
|
| 'Cache-Control'
|
||||||
| 'Content-Encoding';
|
| 'Content-Encoding';
|
||||||
|
|
||||||
|
type CommonResponseHeaderKey = CommonResponseHeadersList | Lowercase<CommonResponseHeadersList>;
|
||||||
|
|
||||||
type BrowserProgressEvent = any;
|
type BrowserProgressEvent = any;
|
||||||
|
|
||||||
declare class AxiosHeaders {
|
declare class AxiosHeaders {
|
||||||
@ -307,7 +309,7 @@ declare namespace axios {
|
|||||||
type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;
|
type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;
|
||||||
|
|
||||||
type RawCommonResponseHeaders = {
|
type RawCommonResponseHeaders = {
|
||||||
[Key in CommonResponseHeadersList]: AxiosHeaderValue;
|
[Key in CommonResponseHeaderKey]: AxiosHeaderValue;
|
||||||
} & {
|
} & {
|
||||||
'set-cookie': string[];
|
'set-cookie': string[];
|
||||||
};
|
};
|
||||||
@ -345,13 +347,35 @@ declare namespace axios {
|
|||||||
protocol?: string;
|
protocol?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type UppercaseMethod = "GET" | "DELETE" | "HEAD" | "OPTIONS" | "POST" | "PUT" | "PATCH" | "PURGE" | "LINK" | "UNLINK";
|
type UppercaseMethod =
|
||||||
|
| 'GET'
|
||||||
|
| 'DELETE'
|
||||||
|
| 'HEAD'
|
||||||
|
| 'OPTIONS'
|
||||||
|
| 'POST'
|
||||||
|
| 'PUT'
|
||||||
|
| 'PATCH'
|
||||||
|
| 'PURGE'
|
||||||
|
| 'LINK'
|
||||||
|
| 'UNLINK';
|
||||||
|
|
||||||
type Method = (UppercaseMethod | Lowercase<UppercaseMethod>) & {};
|
type Method = (UppercaseMethod | Lowercase<UppercaseMethod>) & {};
|
||||||
|
|
||||||
type ResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream' | 'formdata';
|
type ResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream' | 'formdata';
|
||||||
|
|
||||||
type UppercaseResponseEncoding = "ASCII" | "ANSI" | "BINARY" | "BASE64" | "BASE64URL" | "HEX" | "LATIN1" | "UCS-2" | "UCS2" | "UTF-8" | "UTF8" | "UTF16LE";
|
type UppercaseResponseEncoding =
|
||||||
|
| 'ASCII'
|
||||||
|
| 'ANSI'
|
||||||
|
| 'BINARY'
|
||||||
|
| 'BASE64'
|
||||||
|
| 'BASE64URL'
|
||||||
|
| 'HEX'
|
||||||
|
| 'LATIN1'
|
||||||
|
| 'UCS-2'
|
||||||
|
| 'UCS2'
|
||||||
|
| 'UTF-8'
|
||||||
|
| 'UTF8'
|
||||||
|
| 'UTF16LE';
|
||||||
|
|
||||||
type responseEncoding = (UppercaseResponseEncoding | Lowercase<UppercaseResponseEncoding>) & {};
|
type responseEncoding = (UppercaseResponseEncoding | Lowercase<UppercaseResponseEncoding>) & {};
|
||||||
|
|
||||||
|
|||||||
306
index.d.ts
vendored
306
index.d.ts
vendored
@ -1,13 +1,7 @@
|
|||||||
// TypeScript Version: 4.7
|
// TypeScript Version: 4.7
|
||||||
type StringLiteralsOrString<Literals extends string> = Literals | (string & {});
|
type StringLiteralsOrString<Literals extends string> = Literals | (string & {});
|
||||||
|
|
||||||
export type AxiosHeaderValue =
|
export type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;
|
||||||
| AxiosHeaders
|
|
||||||
| string
|
|
||||||
| string[]
|
|
||||||
| number
|
|
||||||
| boolean
|
|
||||||
| null;
|
|
||||||
|
|
||||||
interface RawAxiosHeaders {
|
interface RawAxiosHeaders {
|
||||||
[key: string]: AxiosHeaderValue;
|
[key: string]: AxiosHeaderValue;
|
||||||
@ -24,11 +18,7 @@ type AxiosHeaderMatcher =
|
|||||||
| RegExp
|
| RegExp
|
||||||
| ((this: AxiosHeaders, value: string, name: string) => boolean);
|
| ((this: AxiosHeaders, value: string, name: string) => boolean);
|
||||||
|
|
||||||
type AxiosHeaderParser = (
|
type AxiosHeaderParser = (this: AxiosHeaders, value: AxiosHeaderValue, header: string) => any;
|
||||||
this: AxiosHeaders,
|
|
||||||
value: AxiosHeaderValue,
|
|
||||||
header: string,
|
|
||||||
) => any;
|
|
||||||
|
|
||||||
export class AxiosHeaders {
|
export class AxiosHeaders {
|
||||||
constructor(headers?: RawAxiosHeaders | AxiosHeaders | string);
|
constructor(headers?: RawAxiosHeaders | AxiosHeaders | string);
|
||||||
@ -38,12 +28,9 @@ export class AxiosHeaders {
|
|||||||
set(
|
set(
|
||||||
headerName?: string,
|
headerName?: string,
|
||||||
value?: AxiosHeaderValue,
|
value?: AxiosHeaderValue,
|
||||||
rewrite?: boolean | AxiosHeaderMatcher,
|
rewrite?: boolean | AxiosHeaderMatcher
|
||||||
): AxiosHeaders;
|
|
||||||
set(
|
|
||||||
headers?: RawAxiosHeaders | AxiosHeaders | string,
|
|
||||||
rewrite?: boolean,
|
|
||||||
): AxiosHeaders;
|
): AxiosHeaders;
|
||||||
|
set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean): AxiosHeaders;
|
||||||
|
|
||||||
get(headerName: string, parser: RegExp): RegExpExecArray | null;
|
get(headerName: string, parser: RegExp): RegExpExecArray | null;
|
||||||
get(headerName: string, matcher?: true | AxiosHeaderParser): AxiosHeaderValue;
|
get(headerName: string, matcher?: true | AxiosHeaderParser): AxiosHeaderValue;
|
||||||
@ -57,9 +44,7 @@ export class AxiosHeaders {
|
|||||||
normalize(format: boolean): AxiosHeaders;
|
normalize(format: boolean): AxiosHeaders;
|
||||||
|
|
||||||
concat(
|
concat(
|
||||||
...targets: Array<
|
...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>
|
||||||
AxiosHeaders | RawAxiosHeaders | string | undefined | null
|
|
||||||
>
|
|
||||||
): AxiosHeaders;
|
): AxiosHeaders;
|
||||||
|
|
||||||
toJSON(asStrings?: boolean): RawAxiosHeaders;
|
toJSON(asStrings?: boolean): RawAxiosHeaders;
|
||||||
@ -69,55 +54,35 @@ export class AxiosHeaders {
|
|||||||
static accessor(header: string | string[]): AxiosHeaders;
|
static accessor(header: string | string[]): AxiosHeaders;
|
||||||
|
|
||||||
static concat(
|
static concat(
|
||||||
...targets: Array<
|
...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>
|
||||||
AxiosHeaders | RawAxiosHeaders | string | undefined | null
|
|
||||||
>
|
|
||||||
): AxiosHeaders;
|
): AxiosHeaders;
|
||||||
|
|
||||||
setContentType(
|
setContentType(value: ContentType, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||||
value: ContentType,
|
|
||||||
rewrite?: boolean | AxiosHeaderMatcher,
|
|
||||||
): AxiosHeaders;
|
|
||||||
getContentType(parser?: RegExp): RegExpExecArray | null;
|
getContentType(parser?: RegExp): RegExpExecArray | null;
|
||||||
getContentType(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
getContentType(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
||||||
hasContentType(matcher?: AxiosHeaderMatcher): boolean;
|
hasContentType(matcher?: AxiosHeaderMatcher): boolean;
|
||||||
|
|
||||||
setContentLength(
|
setContentLength(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||||
value: AxiosHeaderValue,
|
|
||||||
rewrite?: boolean | AxiosHeaderMatcher,
|
|
||||||
): AxiosHeaders;
|
|
||||||
getContentLength(parser?: RegExp): RegExpExecArray | null;
|
getContentLength(parser?: RegExp): RegExpExecArray | null;
|
||||||
getContentLength(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
getContentLength(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
||||||
hasContentLength(matcher?: AxiosHeaderMatcher): boolean;
|
hasContentLength(matcher?: AxiosHeaderMatcher): boolean;
|
||||||
|
|
||||||
setAccept(
|
setAccept(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||||
value: AxiosHeaderValue,
|
|
||||||
rewrite?: boolean | AxiosHeaderMatcher,
|
|
||||||
): AxiosHeaders;
|
|
||||||
getAccept(parser?: RegExp): RegExpExecArray | null;
|
getAccept(parser?: RegExp): RegExpExecArray | null;
|
||||||
getAccept(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
getAccept(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
||||||
hasAccept(matcher?: AxiosHeaderMatcher): boolean;
|
hasAccept(matcher?: AxiosHeaderMatcher): boolean;
|
||||||
|
|
||||||
setUserAgent(
|
setUserAgent(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||||
value: AxiosHeaderValue,
|
|
||||||
rewrite?: boolean | AxiosHeaderMatcher,
|
|
||||||
): AxiosHeaders;
|
|
||||||
getUserAgent(parser?: RegExp): RegExpExecArray | null;
|
getUserAgent(parser?: RegExp): RegExpExecArray | null;
|
||||||
getUserAgent(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
getUserAgent(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
||||||
hasUserAgent(matcher?: AxiosHeaderMatcher): boolean;
|
hasUserAgent(matcher?: AxiosHeaderMatcher): boolean;
|
||||||
|
|
||||||
setContentEncoding(
|
setContentEncoding(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||||
value: AxiosHeaderValue,
|
|
||||||
rewrite?: boolean | AxiosHeaderMatcher,
|
|
||||||
): AxiosHeaders;
|
|
||||||
getContentEncoding(parser?: RegExp): RegExpExecArray | null;
|
getContentEncoding(parser?: RegExp): RegExpExecArray | null;
|
||||||
getContentEncoding(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
getContentEncoding(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
||||||
hasContentEncoding(matcher?: AxiosHeaderMatcher): boolean;
|
hasContentEncoding(matcher?: AxiosHeaderMatcher): boolean;
|
||||||
|
|
||||||
setAuthorization(
|
setAuthorization(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||||
value: AxiosHeaderValue,
|
|
||||||
rewrite?: boolean | AxiosHeaderMatcher,
|
|
||||||
): AxiosHeaders;
|
|
||||||
getAuthorization(parser?: RegExp): RegExpExecArray | null;
|
getAuthorization(parser?: RegExp): RegExpExecArray | null;
|
||||||
getAuthorization(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
getAuthorization(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
||||||
hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;
|
hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;
|
||||||
@ -128,57 +93,53 @@ export class AxiosHeaders {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CommonRequestHeadersList =
|
type CommonRequestHeadersList =
|
||||||
| "Accept"
|
| 'Accept'
|
||||||
| "Content-Length"
|
| 'Content-Length'
|
||||||
| "User-Agent"
|
| 'User-Agent'
|
||||||
| "Content-Encoding"
|
| 'Content-Encoding'
|
||||||
| "Authorization"
|
| 'Authorization'
|
||||||
| "Location";
|
| 'Location';
|
||||||
|
|
||||||
type ContentType =
|
type ContentType =
|
||||||
| AxiosHeaderValue
|
| AxiosHeaderValue
|
||||||
| "text/html"
|
| 'text/html'
|
||||||
| "text/plain"
|
| 'text/plain'
|
||||||
| "multipart/form-data"
|
| 'multipart/form-data'
|
||||||
| "application/json"
|
| 'application/json'
|
||||||
| "application/x-www-form-urlencoded"
|
| 'application/x-www-form-urlencoded'
|
||||||
| "application/octet-stream";
|
| 'application/octet-stream';
|
||||||
|
|
||||||
export type RawAxiosRequestHeaders = Partial<
|
export type RawAxiosRequestHeaders = Partial<
|
||||||
RawAxiosHeaders & {
|
RawAxiosHeaders & {
|
||||||
[Key in CommonRequestHeadersList]: AxiosHeaderValue;
|
[Key in CommonRequestHeadersList]: AxiosHeaderValue;
|
||||||
} & {
|
} & {
|
||||||
"Content-Type": ContentType;
|
'Content-Type': ContentType;
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders;
|
export type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders;
|
||||||
|
|
||||||
type CommonResponseHeadersList =
|
type CommonResponseHeadersList =
|
||||||
| "Server"
|
| 'Server'
|
||||||
| "Content-Type"
|
| 'Content-Type'
|
||||||
| "Content-Length"
|
| 'Content-Length'
|
||||||
| "Cache-Control"
|
| 'Cache-Control'
|
||||||
| "Content-Encoding";
|
| 'Content-Encoding';
|
||||||
|
|
||||||
|
type CommonResponseHeaderKey = CommonResponseHeadersList | Lowercase<CommonResponseHeadersList>;
|
||||||
|
|
||||||
type RawCommonResponseHeaders = {
|
type RawCommonResponseHeaders = {
|
||||||
[Key in CommonResponseHeadersList]: AxiosHeaderValue;
|
[Key in CommonResponseHeaderKey]: AxiosHeaderValue;
|
||||||
} & {
|
} & {
|
||||||
"set-cookie": string[];
|
'set-cookie': string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type RawAxiosResponseHeaders = Partial<
|
export type RawAxiosResponseHeaders = Partial<RawAxiosHeaders & RawCommonResponseHeaders>;
|
||||||
RawAxiosHeaders & RawCommonResponseHeaders
|
|
||||||
>;
|
|
||||||
|
|
||||||
export type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders;
|
export type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders;
|
||||||
|
|
||||||
export interface AxiosRequestTransformer {
|
export interface AxiosRequestTransformer {
|
||||||
(
|
(this: InternalAxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any;
|
||||||
this: InternalAxiosRequestConfig,
|
|
||||||
data: any,
|
|
||||||
headers: AxiosRequestHeaders,
|
|
||||||
): any;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosResponseTransformer {
|
export interface AxiosResponseTransformer {
|
||||||
@ -186,7 +147,7 @@ export interface AxiosResponseTransformer {
|
|||||||
this: InternalAxiosRequestConfig,
|
this: InternalAxiosRequestConfig,
|
||||||
data: any,
|
data: any,
|
||||||
headers: AxiosResponseHeaders,
|
headers: AxiosResponseHeaders,
|
||||||
status?: number,
|
status?: number
|
||||||
): any;
|
): any;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,22 +233,47 @@ export enum HttpStatusCode {
|
|||||||
NetworkAuthenticationRequired = 511,
|
NetworkAuthenticationRequired = 511,
|
||||||
}
|
}
|
||||||
|
|
||||||
type UppercaseMethod = "GET" | "DELETE" | "HEAD" | "OPTIONS" | "POST" | "PUT" | "PATCH" | "PURGE" | "LINK" | "UNLINK";
|
type UppercaseMethod =
|
||||||
|
| 'GET'
|
||||||
|
| 'DELETE'
|
||||||
|
| 'HEAD'
|
||||||
|
| 'OPTIONS'
|
||||||
|
| 'POST'
|
||||||
|
| 'PUT'
|
||||||
|
| 'PATCH'
|
||||||
|
| 'PURGE'
|
||||||
|
| 'LINK'
|
||||||
|
| 'UNLINK';
|
||||||
|
|
||||||
export type Method = (UppercaseMethod | Lowercase<UppercaseMethod>) & {};
|
export type Method = (UppercaseMethod | Lowercase<UppercaseMethod>) & {};
|
||||||
|
|
||||||
export type ResponseType =
|
export type ResponseType =
|
||||||
| "arraybuffer"
|
| 'arraybuffer'
|
||||||
| "blob"
|
| 'blob'
|
||||||
| "document"
|
| 'document'
|
||||||
| "json"
|
| 'json'
|
||||||
| "text"
|
| 'text'
|
||||||
| "stream"
|
| 'stream'
|
||||||
| "formdata";
|
| 'formdata';
|
||||||
|
|
||||||
type UppercaseResponseEncoding = "ASCII" | "ANSI" | "BINARY" | "BASE64" | "BASE64URL" | "HEX" | "LATIN1" | "UCS-2" | "UCS2" | "UTF-8" | "UTF8" | "UTF16LE";
|
type UppercaseResponseEncoding =
|
||||||
|
| 'ASCII'
|
||||||
|
| 'ANSI'
|
||||||
|
| 'BINARY'
|
||||||
|
| 'BASE64'
|
||||||
|
| 'BASE64URL'
|
||||||
|
| 'HEX'
|
||||||
|
| 'LATIN1'
|
||||||
|
| 'UCS-2'
|
||||||
|
| 'UCS2'
|
||||||
|
| 'UTF-8'
|
||||||
|
| 'UTF8'
|
||||||
|
| 'UTF16LE';
|
||||||
|
|
||||||
export type responseEncoding = (UppercaseResponseEncoding | Lowercase<UppercaseResponseEncoding>) & {};
|
export type responseEncoding = (
|
||||||
|
| UppercaseResponseEncoding
|
||||||
|
| Lowercase<UppercaseResponseEncoding>
|
||||||
|
) & {};
|
||||||
|
|
||||||
export interface TransitionalOptions {
|
export interface TransitionalOptions {
|
||||||
silentJSONParsing?: boolean;
|
silentJSONParsing?: boolean;
|
||||||
@ -315,7 +301,7 @@ export interface SerializerVisitor {
|
|||||||
value: any,
|
value: any,
|
||||||
key: string | number,
|
key: string | number,
|
||||||
path: null | Array<string | number>,
|
path: null | Array<string | number>,
|
||||||
helpers: FormDataVisitorHelpers,
|
helpers: FormDataVisitorHelpers
|
||||||
): boolean;
|
): boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,7 +349,7 @@ export interface AxiosProgressEvent {
|
|||||||
|
|
||||||
type Milliseconds = number;
|
type Milliseconds = number;
|
||||||
|
|
||||||
type AxiosAdapterName = StringLiteralsOrString<"xhr" | "http" | "fetch">;
|
type AxiosAdapterName = StringLiteralsOrString<'xhr' | 'http' | 'fetch'>;
|
||||||
|
|
||||||
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
||||||
|
|
||||||
@ -408,7 +394,7 @@ export interface AxiosRequestConfig<D = any> {
|
|||||||
responseDetails: {
|
responseDetails: {
|
||||||
headers: Record<string, string>;
|
headers: Record<string, string>;
|
||||||
statusCode: HttpStatusCode;
|
statusCode: HttpStatusCode;
|
||||||
},
|
}
|
||||||
) => void;
|
) => void;
|
||||||
socketPath?: string | null;
|
socketPath?: string | null;
|
||||||
transport?: any;
|
transport?: any;
|
||||||
@ -422,24 +408,11 @@ export interface AxiosRequestConfig<D = any> {
|
|||||||
insecureHTTPParser?: boolean;
|
insecureHTTPParser?: boolean;
|
||||||
env?: {
|
env?: {
|
||||||
FormData?: new (...args: any[]) => object;
|
FormData?: new (...args: any[]) => object;
|
||||||
fetch?: (
|
fetch?: (input: URL | Request | string, init?: RequestInit) => Promise<Response>;
|
||||||
input: URL | Request | string,
|
Request?: new (input: URL | Request | string, init?: RequestInit) => Request;
|
||||||
init?: RequestInit,
|
|
||||||
) => Promise<Response>;
|
|
||||||
Request?: new (
|
|
||||||
input: URL | Request | string,
|
|
||||||
init?: RequestInit,
|
|
||||||
) => Request;
|
|
||||||
Response?: new (
|
Response?: new (
|
||||||
body?:
|
body?: ArrayBuffer | ArrayBufferView | Blob | FormData | URLSearchParams | string | null,
|
||||||
| ArrayBuffer
|
init?: ResponseInit
|
||||||
| ArrayBufferView
|
|
||||||
| Blob
|
|
||||||
| FormData
|
|
||||||
| URLSearchParams
|
|
||||||
| string
|
|
||||||
| null,
|
|
||||||
init?: ResponseInit,
|
|
||||||
) => Response;
|
) => Response;
|
||||||
};
|
};
|
||||||
formSerializer?: FormSerializerOptions;
|
formSerializer?: FormSerializerOptions;
|
||||||
@ -451,26 +424,18 @@ export interface AxiosRequestConfig<D = any> {
|
|||||||
cb: (
|
cb: (
|
||||||
err: Error | null,
|
err: Error | null,
|
||||||
address: LookupAddress | LookupAddress[],
|
address: LookupAddress | LookupAddress[],
|
||||||
family?: AddressFamily,
|
family?: AddressFamily
|
||||||
) => void,
|
) => void
|
||||||
) => void)
|
) => void)
|
||||||
| ((
|
| ((
|
||||||
hostname: string,
|
hostname: string,
|
||||||
options: object,
|
options: object
|
||||||
) => Promise<
|
) => Promise<
|
||||||
| [
|
[address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress
|
||||||
address: LookupAddressEntry | LookupAddressEntry[],
|
|
||||||
family?: AddressFamily,
|
|
||||||
]
|
|
||||||
| LookupAddress
|
|
||||||
>);
|
>);
|
||||||
withXSRFToken?:
|
withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined);
|
||||||
| boolean
|
|
||||||
| ((config: InternalAxiosRequestConfig) => boolean | undefined);
|
|
||||||
parseReviver?: (this: any, key: string, value: any) => any;
|
parseReviver?: (this: any, key: string, value: any) => any;
|
||||||
fetchOptions?:
|
fetchOptions?: Omit<RequestInit, 'body' | 'headers' | 'method' | 'signal'> | Record<string, any>;
|
||||||
| Omit<RequestInit, "body" | "headers" | "method" | "signal">
|
|
||||||
| Record<string, any>;
|
|
||||||
httpVersion?: 1 | 2;
|
httpVersion?: 1 | 2;
|
||||||
http2Options?: Record<string, any> & {
|
http2Options?: Record<string, any> & {
|
||||||
sessionTimeout?: number;
|
sessionTimeout?: number;
|
||||||
@ -480,9 +445,7 @@ export interface AxiosRequestConfig<D = any> {
|
|||||||
// Alias
|
// Alias
|
||||||
export type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;
|
export type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;
|
||||||
|
|
||||||
export interface InternalAxiosRequestConfig<
|
export interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig<D> {
|
||||||
D = any,
|
|
||||||
> extends AxiosRequestConfig<D> {
|
|
||||||
headers: AxiosRequestHeaders;
|
headers: AxiosRequestHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,17 +463,11 @@ export interface HeadersDefaults {
|
|||||||
unlink?: RawAxiosRequestHeaders;
|
unlink?: RawAxiosRequestHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosDefaults<D = any> extends Omit<
|
export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
||||||
AxiosRequestConfig<D>,
|
|
||||||
"headers"
|
|
||||||
> {
|
|
||||||
headers: HeadersDefaults;
|
headers: HeadersDefaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateAxiosDefaults<D = any> extends Omit<
|
export interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
||||||
AxiosRequestConfig<D>,
|
|
||||||
"headers"
|
|
||||||
> {
|
|
||||||
headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>;
|
headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,7 +486,7 @@ export class AxiosError<T = unknown, D = any> extends Error {
|
|||||||
code?: string,
|
code?: string,
|
||||||
config?: InternalAxiosRequestConfig<D>,
|
config?: InternalAxiosRequestConfig<D>,
|
||||||
request?: any,
|
request?: any,
|
||||||
response?: AxiosResponse<T, D>,
|
response?: AxiosResponse<T, D>
|
||||||
);
|
);
|
||||||
|
|
||||||
config?: InternalAxiosRequestConfig<D>;
|
config?: InternalAxiosRequestConfig<D>;
|
||||||
@ -547,24 +504,24 @@ export class AxiosError<T = unknown, D = any> extends Error {
|
|||||||
config?: InternalAxiosRequestConfig<D>,
|
config?: InternalAxiosRequestConfig<D>,
|
||||||
request?: any,
|
request?: any,
|
||||||
response?: AxiosResponse<T, D>,
|
response?: AxiosResponse<T, D>,
|
||||||
customProps?: object,
|
customProps?: object
|
||||||
): AxiosError<T, D>;
|
): AxiosError<T, D>;
|
||||||
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
|
static readonly ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
||||||
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
|
static readonly ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
||||||
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION";
|
static readonly ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
||||||
static readonly ERR_NETWORK = "ERR_NETWORK";
|
static readonly ERR_NETWORK = 'ERR_NETWORK';
|
||||||
static readonly ERR_DEPRECATED = "ERR_DEPRECATED";
|
static readonly ERR_DEPRECATED = 'ERR_DEPRECATED';
|
||||||
static readonly ERR_BAD_RESPONSE = "ERR_BAD_RESPONSE";
|
static readonly ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
||||||
static readonly ERR_BAD_REQUEST = "ERR_BAD_REQUEST";
|
static readonly ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
||||||
static readonly ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT";
|
static readonly ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
||||||
static readonly ERR_INVALID_URL = "ERR_INVALID_URL";
|
static readonly ERR_INVALID_URL = 'ERR_INVALID_URL';
|
||||||
static readonly ERR_CANCELED = "ERR_CANCELED";
|
static readonly ERR_CANCELED = 'ERR_CANCELED';
|
||||||
static readonly ECONNABORTED = "ECONNABORTED";
|
static readonly ECONNABORTED = 'ECONNABORTED';
|
||||||
static readonly ETIMEDOUT = "ETIMEDOUT";
|
static readonly ETIMEDOUT = 'ETIMEDOUT';
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CanceledError<T> extends AxiosError<T> {
|
export class CanceledError<T> extends AxiosError<T> {
|
||||||
readonly name: "CanceledError";
|
readonly name: 'CanceledError';
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AxiosPromise<T = any> = Promise<AxiosResponse<T>>;
|
export type AxiosPromise<T = any> = Promise<AxiosResponse<T>>;
|
||||||
@ -608,12 +565,12 @@ type AxiosInterceptorRejected = (error: any) => any;
|
|||||||
type AxiosRequestInterceptorUse<T> = (
|
type AxiosRequestInterceptorUse<T> = (
|
||||||
onFulfilled?: AxiosInterceptorFulfilled<T> | null,
|
onFulfilled?: AxiosInterceptorFulfilled<T> | null,
|
||||||
onRejected?: AxiosInterceptorRejected | null,
|
onRejected?: AxiosInterceptorRejected | null,
|
||||||
options?: AxiosInterceptorOptions,
|
options?: AxiosInterceptorOptions
|
||||||
) => number;
|
) => number;
|
||||||
|
|
||||||
type AxiosResponseInterceptorUse<T> = (
|
type AxiosResponseInterceptorUse<T> = (
|
||||||
onFulfilled?: AxiosInterceptorFulfilled<T> | null,
|
onFulfilled?: AxiosInterceptorFulfilled<T> | null,
|
||||||
onRejected?: AxiosInterceptorRejected | null,
|
onRejected?: AxiosInterceptorRejected | null
|
||||||
) => number;
|
) => number;
|
||||||
|
|
||||||
interface AxiosInterceptorHandler<T> {
|
interface AxiosInterceptorHandler<T> {
|
||||||
@ -624,9 +581,7 @@ interface AxiosInterceptorHandler<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosInterceptorManager<V> {
|
export interface AxiosInterceptorManager<V> {
|
||||||
use: V extends AxiosResponse
|
use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
|
||||||
? AxiosResponseInterceptorUse<V>
|
|
||||||
: AxiosRequestInterceptorUse<V>;
|
|
||||||
eject(id: number): void;
|
eject(id: number): void;
|
||||||
clear(): void;
|
clear(): void;
|
||||||
handlers?: Array<AxiosInterceptorHandler<V>>;
|
handlers?: Array<AxiosInterceptorHandler<V>>;
|
||||||
@ -640,68 +595,61 @@ export class Axios {
|
|||||||
response: AxiosInterceptorManager<AxiosResponse>;
|
response: AxiosInterceptorManager<AxiosResponse>;
|
||||||
};
|
};
|
||||||
getUri(config?: AxiosRequestConfig): string;
|
getUri(config?: AxiosRequestConfig): string;
|
||||||
request<T = any, R = AxiosResponse<T>, D = any>(
|
request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
||||||
config: AxiosRequestConfig<D>,
|
|
||||||
): Promise<R>;
|
|
||||||
get<T = any, R = AxiosResponse<T>, D = any>(
|
get<T = any, R = AxiosResponse<T>, D = any>(
|
||||||
url: string,
|
url: string,
|
||||||
config?: AxiosRequestConfig<D>,
|
config?: AxiosRequestConfig<D>
|
||||||
): Promise<R>;
|
): Promise<R>;
|
||||||
delete<T = any, R = AxiosResponse<T>, D = any>(
|
delete<T = any, R = AxiosResponse<T>, D = any>(
|
||||||
url: string,
|
url: string,
|
||||||
config?: AxiosRequestConfig<D>,
|
config?: AxiosRequestConfig<D>
|
||||||
): Promise<R>;
|
): Promise<R>;
|
||||||
head<T = any, R = AxiosResponse<T>, D = any>(
|
head<T = any, R = AxiosResponse<T>, D = any>(
|
||||||
url: string,
|
url: string,
|
||||||
config?: AxiosRequestConfig<D>,
|
config?: AxiosRequestConfig<D>
|
||||||
): Promise<R>;
|
): Promise<R>;
|
||||||
options<T = any, R = AxiosResponse<T>, D = any>(
|
options<T = any, R = AxiosResponse<T>, D = any>(
|
||||||
url: string,
|
url: string,
|
||||||
config?: AxiosRequestConfig<D>,
|
config?: AxiosRequestConfig<D>
|
||||||
): Promise<R>;
|
): Promise<R>;
|
||||||
post<T = any, R = AxiosResponse<T>, D = any>(
|
post<T = any, R = AxiosResponse<T>, D = any>(
|
||||||
url: string,
|
url: string,
|
||||||
data?: D,
|
data?: D,
|
||||||
config?: AxiosRequestConfig<D>,
|
config?: AxiosRequestConfig<D>
|
||||||
): Promise<R>;
|
): Promise<R>;
|
||||||
put<T = any, R = AxiosResponse<T>, D = any>(
|
put<T = any, R = AxiosResponse<T>, D = any>(
|
||||||
url: string,
|
url: string,
|
||||||
data?: D,
|
data?: D,
|
||||||
config?: AxiosRequestConfig<D>,
|
config?: AxiosRequestConfig<D>
|
||||||
): Promise<R>;
|
): Promise<R>;
|
||||||
patch<T = any, R = AxiosResponse<T>, D = any>(
|
patch<T = any, R = AxiosResponse<T>, D = any>(
|
||||||
url: string,
|
url: string,
|
||||||
data?: D,
|
data?: D,
|
||||||
config?: AxiosRequestConfig<D>,
|
config?: AxiosRequestConfig<D>
|
||||||
): Promise<R>;
|
): Promise<R>;
|
||||||
postForm<T = any, R = AxiosResponse<T>, D = any>(
|
postForm<T = any, R = AxiosResponse<T>, D = any>(
|
||||||
url: string,
|
url: string,
|
||||||
data?: D,
|
data?: D,
|
||||||
config?: AxiosRequestConfig<D>,
|
config?: AxiosRequestConfig<D>
|
||||||
): Promise<R>;
|
): Promise<R>;
|
||||||
putForm<T = any, R = AxiosResponse<T>, D = any>(
|
putForm<T = any, R = AxiosResponse<T>, D = any>(
|
||||||
url: string,
|
url: string,
|
||||||
data?: D,
|
data?: D,
|
||||||
config?: AxiosRequestConfig<D>,
|
config?: AxiosRequestConfig<D>
|
||||||
): Promise<R>;
|
): Promise<R>;
|
||||||
patchForm<T = any, R = AxiosResponse<T>, D = any>(
|
patchForm<T = any, R = AxiosResponse<T>, D = any>(
|
||||||
url: string,
|
url: string,
|
||||||
data?: D,
|
data?: D,
|
||||||
config?: AxiosRequestConfig<D>,
|
config?: AxiosRequestConfig<D>
|
||||||
): Promise<R>;
|
): Promise<R>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosInstance extends Axios {
|
export interface AxiosInstance extends Axios {
|
||||||
<T = any, R = AxiosResponse<T>, D = any>(
|
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
||||||
config: AxiosRequestConfig<D>,
|
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||||
): Promise<R>;
|
|
||||||
<T = any, R = AxiosResponse<T>, D = any>(
|
|
||||||
url: string,
|
|
||||||
config?: AxiosRequestConfig<D>,
|
|
||||||
): Promise<R>;
|
|
||||||
|
|
||||||
create(config?: CreateAxiosDefaults): AxiosInstance;
|
create(config?: CreateAxiosDefaults): AxiosInstance;
|
||||||
defaults: Omit<AxiosDefaults, "headers"> & {
|
defaults: Omit<AxiosDefaults, 'headers'> & {
|
||||||
headers: HeadersDefaults & {
|
headers: HeadersDefaults & {
|
||||||
[key: string]: AxiosHeaderValue;
|
[key: string]: AxiosHeaderValue;
|
||||||
};
|
};
|
||||||
@ -719,22 +667,18 @@ export interface GenericHTMLFormElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getAdapter(
|
export function getAdapter(
|
||||||
adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined,
|
adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined
|
||||||
): AxiosAdapter;
|
): AxiosAdapter;
|
||||||
|
|
||||||
export function toFormData(
|
export function toFormData(
|
||||||
sourceObj: object,
|
sourceObj: object,
|
||||||
targetFormData?: GenericFormData,
|
targetFormData?: GenericFormData,
|
||||||
options?: FormSerializerOptions,
|
options?: FormSerializerOptions
|
||||||
): GenericFormData;
|
): GenericFormData;
|
||||||
|
|
||||||
export function formToJSON(
|
export function formToJSON(form: GenericFormData | GenericHTMLFormElement): object;
|
||||||
form: GenericFormData | GenericHTMLFormElement,
|
|
||||||
): object;
|
|
||||||
|
|
||||||
export function isAxiosError<T = any, D = any>(
|
export function isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>;
|
||||||
payload: any,
|
|
||||||
): payload is AxiosError<T, D>;
|
|
||||||
|
|
||||||
export function spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
|
export function spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
|
||||||
|
|
||||||
@ -744,7 +688,7 @@ export function all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
|
|||||||
|
|
||||||
export function mergeConfig<D = any>(
|
export function mergeConfig<D = any>(
|
||||||
config1: AxiosRequestConfig<D>,
|
config1: AxiosRequestConfig<D>,
|
||||||
config2: AxiosRequestConfig<D>,
|
config2: AxiosRequestConfig<D>
|
||||||
): AxiosRequestConfig<D>;
|
): AxiosRequestConfig<D>;
|
||||||
|
|
||||||
export interface AxiosStatic extends AxiosInstance {
|
export interface AxiosStatic extends AxiosInstance {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user