Path: blob/master/node_modules/axios/index.d.ts
2591 views
// TypeScript Version: 3.012export type AxiosRequestHeaders = Record<string, string>;34export type AxiosResponseHeaders = Record<string, string> & {5"set-cookie"?: string[]6};78export interface AxiosRequestTransformer {9(data: any, headers?: AxiosRequestHeaders): any;10}1112export interface AxiosResponseTransformer {13(data: any, headers?: AxiosResponseHeaders): any;14}1516export interface AxiosAdapter {17(config: AxiosRequestConfig): AxiosPromise;18}1920export interface AxiosBasicCredentials {21username: string;22password: string;23}2425export interface AxiosProxyConfig {26host: string;27port: number;28auth?: {29username: string;30password: string;31};32protocol?: string;33}3435export type Method =36| 'get' | 'GET'37| 'delete' | 'DELETE'38| 'head' | 'HEAD'39| 'options' | 'OPTIONS'40| 'post' | 'POST'41| 'put' | 'PUT'42| 'patch' | 'PATCH'43| 'purge' | 'PURGE'44| 'link' | 'LINK'45| 'unlink' | 'UNLINK';4647export type ResponseType =48| 'arraybuffer'49| 'blob'50| 'document'51| 'json'52| 'text'53| 'stream';5455export interface TransitionalOptions {56silentJSONParsing?: boolean;57forcedJSONParsing?: boolean;58clarifyTimeoutError?: boolean;59}6061export interface AxiosRequestConfig<D = any> {62url?: string;63method?: Method;64baseURL?: string;65transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];66transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];67headers?: AxiosRequestHeaders;68params?: any;69paramsSerializer?: (params: any) => string;70data?: D;71timeout?: number;72timeoutErrorMessage?: string;73withCredentials?: boolean;74adapter?: AxiosAdapter;75auth?: AxiosBasicCredentials;76responseType?: ResponseType;77xsrfCookieName?: string;78xsrfHeaderName?: string;79onUploadProgress?: (progressEvent: any) => void;80onDownloadProgress?: (progressEvent: any) => void;81maxContentLength?: number;82validateStatus?: ((status: number) => boolean) | null;83maxBodyLength?: number;84maxRedirects?: number;85socketPath?: string | null;86httpAgent?: any;87httpsAgent?: any;88proxy?: AxiosProxyConfig | false;89cancelToken?: CancelToken;90decompress?: boolean;91transitional?: TransitionalOptions;92signal?: AbortSignal;93insecureHTTPParser?: boolean;94}9596export interface HeadersDefaults {97common: AxiosRequestHeaders;98delete: AxiosRequestHeaders;99get: AxiosRequestHeaders;100head: AxiosRequestHeaders;101post: AxiosRequestHeaders;102put: AxiosRequestHeaders;103patch: AxiosRequestHeaders;104options?: AxiosRequestHeaders;105purge?: AxiosRequestHeaders;106link?: AxiosRequestHeaders;107unlink?: AxiosRequestHeaders;108}109110export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {111headers: HeadersDefaults;112}113114export interface AxiosResponse<T = any, D = any> {115data: T;116status: number;117statusText: string;118headers: AxiosResponseHeaders;119config: AxiosRequestConfig<D>;120request?: any;121}122123export interface AxiosError<T = any, D = any> extends Error {124config: AxiosRequestConfig<D>;125code?: string;126request?: any;127response?: AxiosResponse<T, D>;128isAxiosError: boolean;129toJSON: () => object;130}131132export interface AxiosPromise<T = any> extends Promise<AxiosResponse<T>> {133}134135export interface CancelStatic {136new (message?: string): Cancel;137}138139export interface Cancel {140message: string;141}142143export interface Canceler {144(message?: string): void;145}146147export interface CancelTokenStatic {148new (executor: (cancel: Canceler) => void): CancelToken;149source(): CancelTokenSource;150}151152export interface CancelToken {153promise: Promise<Cancel>;154reason?: Cancel;155throwIfRequested(): void;156}157158export interface CancelTokenSource {159token: CancelToken;160cancel: Canceler;161}162163export interface AxiosInterceptorManager<V> {164use<T = V>(onFulfilled?: (value: V) => T | Promise<T>, onRejected?: (error: any) => any): number;165eject(id: number): void;166}167168export class Axios {169constructor(config?: AxiosRequestConfig);170defaults: AxiosDefaults;171interceptors: {172request: AxiosInterceptorManager<AxiosRequestConfig>;173response: AxiosInterceptorManager<AxiosResponse>;174};175getUri(config?: AxiosRequestConfig): string;176request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;177get<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;178delete<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;179head<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;180options<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;181post<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;182put<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;183patch<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;184}185186export interface AxiosInstance extends Axios {187(config: AxiosRequestConfig): AxiosPromise;188(url: string, config?: AxiosRequestConfig): AxiosPromise;189}190191export interface AxiosStatic extends AxiosInstance {192create(config?: AxiosRequestConfig): AxiosInstance;193Cancel: CancelStatic;194CancelToken: CancelTokenStatic;195Axios: typeof Axios;196readonly VERSION: string;197isCancel(value: any): boolean;198all<T>(values: Array<T | Promise<T>>): Promise<T[]>;199spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;200isAxiosError(payload: any): payload is AxiosError;201}202203declare const axios: AxiosStatic;204205export default axios;206207208