index.d.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. // TypeScript Version: 4.7
  2. type StringLiteralsOrString<Literals extends string> = Literals | (string & {});
  3. export type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;
  4. interface RawAxiosHeaders {
  5. [key: string]: AxiosHeaderValue;
  6. }
  7. type MethodsHeaders = Partial<
  8. {
  9. [Key in Method as Lowercase<Key>]: AxiosHeaders;
  10. } & { common: AxiosHeaders }
  11. >;
  12. type AxiosHeaderMatcher =
  13. | string
  14. | RegExp
  15. | ((this: AxiosHeaders, value: string, name: string) => boolean);
  16. type AxiosHeaderParser = (this: AxiosHeaders, value: AxiosHeaderValue, header: string) => any;
  17. export class AxiosHeaders {
  18. constructor(headers?: RawAxiosHeaders | AxiosHeaders | string);
  19. [key: string]: any;
  20. set(
  21. headerName?: string,
  22. value?: AxiosHeaderValue,
  23. rewrite?: boolean | AxiosHeaderMatcher
  24. ): AxiosHeaders;
  25. set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean): AxiosHeaders;
  26. get(headerName: string, parser: RegExp): RegExpExecArray | null;
  27. get(headerName: string, matcher?: true | AxiosHeaderParser): AxiosHeaderValue;
  28. has(header: string, matcher?: AxiosHeaderMatcher): boolean;
  29. delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean;
  30. clear(matcher?: AxiosHeaderMatcher): boolean;
  31. normalize(format: boolean): AxiosHeaders;
  32. concat(
  33. ...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>
  34. ): AxiosHeaders;
  35. toJSON(asStrings?: boolean): RawAxiosHeaders;
  36. static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;
  37. static accessor(header: string | string[]): AxiosHeaders;
  38. static concat(
  39. ...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>
  40. ): AxiosHeaders;
  41. setContentType(value: ContentType, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
  42. getContentType(parser?: RegExp): RegExpExecArray | null;
  43. getContentType(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
  44. hasContentType(matcher?: AxiosHeaderMatcher): boolean;
  45. setContentLength(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
  46. getContentLength(parser?: RegExp): RegExpExecArray | null;
  47. getContentLength(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
  48. hasContentLength(matcher?: AxiosHeaderMatcher): boolean;
  49. setAccept(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
  50. getAccept(parser?: RegExp): RegExpExecArray | null;
  51. getAccept(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
  52. hasAccept(matcher?: AxiosHeaderMatcher): boolean;
  53. setUserAgent(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
  54. getUserAgent(parser?: RegExp): RegExpExecArray | null;
  55. getUserAgent(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
  56. hasUserAgent(matcher?: AxiosHeaderMatcher): boolean;
  57. setContentEncoding(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
  58. getContentEncoding(parser?: RegExp): RegExpExecArray | null;
  59. getContentEncoding(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
  60. hasContentEncoding(matcher?: AxiosHeaderMatcher): boolean;
  61. setAuthorization(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
  62. getAuthorization(parser?: RegExp): RegExpExecArray | null;
  63. getAuthorization(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
  64. hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;
  65. getSetCookie(): string[];
  66. [Symbol.iterator](): IterableIterator<[string, AxiosHeaderValue]>;
  67. }
  68. type CommonRequestHeadersList =
  69. | 'Accept'
  70. | 'Content-Length'
  71. | 'User-Agent'
  72. | 'Content-Encoding'
  73. | 'Authorization'
  74. | 'Location';
  75. type ContentType =
  76. | AxiosHeaderValue
  77. | 'text/html'
  78. | 'text/plain'
  79. | 'multipart/form-data'
  80. | 'application/json'
  81. | 'application/x-www-form-urlencoded'
  82. | 'application/octet-stream';
  83. export type RawAxiosRequestHeaders = Partial<
  84. RawAxiosHeaders & {
  85. [Key in CommonRequestHeadersList]: AxiosHeaderValue;
  86. } & {
  87. 'Content-Type': ContentType;
  88. }
  89. >;
  90. export type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders;
  91. type CommonResponseHeadersList =
  92. | 'Server'
  93. | 'Content-Type'
  94. | 'Content-Length'
  95. | 'Cache-Control'
  96. | 'Content-Encoding';
  97. type CommonResponseHeaderKey = CommonResponseHeadersList | Lowercase<CommonResponseHeadersList>;
  98. type RawCommonResponseHeaders = {
  99. [Key in CommonResponseHeaderKey]: AxiosHeaderValue;
  100. } & {
  101. 'set-cookie': string[];
  102. };
  103. export type RawAxiosResponseHeaders = Partial<RawAxiosHeaders & RawCommonResponseHeaders>;
  104. export type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders;
  105. export interface AxiosRequestTransformer {
  106. (this: InternalAxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any;
  107. }
  108. export interface AxiosResponseTransformer {
  109. (
  110. this: InternalAxiosRequestConfig,
  111. data: any,
  112. headers: AxiosResponseHeaders,
  113. status?: number
  114. ): any;
  115. }
  116. export interface AxiosAdapter {
  117. (config: InternalAxiosRequestConfig): AxiosPromise;
  118. }
  119. export interface AxiosBasicCredentials {
  120. username: string;
  121. password: string;
  122. }
  123. export interface AxiosProxyConfig {
  124. host: string;
  125. port: number;
  126. auth?: AxiosBasicCredentials;
  127. protocol?: string;
  128. }
  129. export enum HttpStatusCode {
  130. Continue = 100,
  131. SwitchingProtocols = 101,
  132. Processing = 102,
  133. EarlyHints = 103,
  134. Ok = 200,
  135. Created = 201,
  136. Accepted = 202,
  137. NonAuthoritativeInformation = 203,
  138. NoContent = 204,
  139. ResetContent = 205,
  140. PartialContent = 206,
  141. MultiStatus = 207,
  142. AlreadyReported = 208,
  143. ImUsed = 226,
  144. MultipleChoices = 300,
  145. MovedPermanently = 301,
  146. Found = 302,
  147. SeeOther = 303,
  148. NotModified = 304,
  149. UseProxy = 305,
  150. Unused = 306,
  151. TemporaryRedirect = 307,
  152. PermanentRedirect = 308,
  153. BadRequest = 400,
  154. Unauthorized = 401,
  155. PaymentRequired = 402,
  156. Forbidden = 403,
  157. NotFound = 404,
  158. MethodNotAllowed = 405,
  159. NotAcceptable = 406,
  160. ProxyAuthenticationRequired = 407,
  161. RequestTimeout = 408,
  162. Conflict = 409,
  163. Gone = 410,
  164. LengthRequired = 411,
  165. PreconditionFailed = 412,
  166. PayloadTooLarge = 413,
  167. UriTooLong = 414,
  168. UnsupportedMediaType = 415,
  169. RangeNotSatisfiable = 416,
  170. ExpectationFailed = 417,
  171. ImATeapot = 418,
  172. MisdirectedRequest = 421,
  173. UnprocessableEntity = 422,
  174. Locked = 423,
  175. FailedDependency = 424,
  176. TooEarly = 425,
  177. UpgradeRequired = 426,
  178. PreconditionRequired = 428,
  179. TooManyRequests = 429,
  180. RequestHeaderFieldsTooLarge = 431,
  181. UnavailableForLegalReasons = 451,
  182. InternalServerError = 500,
  183. NotImplemented = 501,
  184. BadGateway = 502,
  185. ServiceUnavailable = 503,
  186. GatewayTimeout = 504,
  187. HttpVersionNotSupported = 505,
  188. VariantAlsoNegotiates = 506,
  189. InsufficientStorage = 507,
  190. LoopDetected = 508,
  191. NotExtended = 510,
  192. NetworkAuthenticationRequired = 511,
  193. }
  194. type UppercaseMethod =
  195. | 'GET'
  196. | 'DELETE'
  197. | 'HEAD'
  198. | 'OPTIONS'
  199. | 'POST'
  200. | 'PUT'
  201. | 'PATCH'
  202. | 'PURGE'
  203. | 'LINK'
  204. | 'UNLINK';
  205. export type Method = (UppercaseMethod | Lowercase<UppercaseMethod>) & {};
  206. export type ResponseType =
  207. | 'arraybuffer'
  208. | 'blob'
  209. | 'document'
  210. | 'json'
  211. | 'text'
  212. | 'stream'
  213. | 'formdata';
  214. type UppercaseResponseEncoding =
  215. | 'ASCII'
  216. | 'ANSI'
  217. | 'BINARY'
  218. | 'BASE64'
  219. | 'BASE64URL'
  220. | 'HEX'
  221. | 'LATIN1'
  222. | 'UCS-2'
  223. | 'UCS2'
  224. | 'UTF-8'
  225. | 'UTF8'
  226. | 'UTF16LE';
  227. export type responseEncoding = (
  228. | UppercaseResponseEncoding
  229. | Lowercase<UppercaseResponseEncoding>
  230. ) & {};
  231. export interface TransitionalOptions {
  232. silentJSONParsing?: boolean;
  233. forcedJSONParsing?: boolean;
  234. clarifyTimeoutError?: boolean;
  235. legacyInterceptorReqResOrdering?: boolean;
  236. }
  237. export interface GenericAbortSignal {
  238. readonly aborted: boolean;
  239. onabort?: ((...args: any) => any) | null;
  240. addEventListener?: (...args: any) => any;
  241. removeEventListener?: (...args: any) => any;
  242. }
  243. export interface FormDataVisitorHelpers {
  244. defaultVisitor: SerializerVisitor;
  245. convertValue: (value: any) => any;
  246. isVisitable: (value: any) => boolean;
  247. }
  248. export interface SerializerVisitor {
  249. (
  250. this: GenericFormData,
  251. value: any,
  252. key: string | number,
  253. path: null | Array<string | number>,
  254. helpers: FormDataVisitorHelpers
  255. ): boolean;
  256. }
  257. export interface SerializerOptions {
  258. visitor?: SerializerVisitor;
  259. dots?: boolean;
  260. metaTokens?: boolean;
  261. indexes?: boolean | null;
  262. }
  263. // tslint:disable-next-line
  264. export interface FormSerializerOptions extends SerializerOptions {}
  265. export interface ParamEncoder {
  266. (value: any, defaultEncoder: (value: any) => any): any;
  267. }
  268. export interface CustomParamsSerializer {
  269. (params: Record<string, any>, options?: ParamsSerializerOptions): string;
  270. }
  271. export interface ParamsSerializerOptions extends SerializerOptions {
  272. encode?: ParamEncoder;
  273. serialize?: CustomParamsSerializer;
  274. }
  275. type MaxUploadRate = number;
  276. type MaxDownloadRate = number;
  277. type BrowserProgressEvent = any;
  278. export interface AxiosProgressEvent {
  279. loaded: number;
  280. total?: number;
  281. progress?: number;
  282. bytes: number;
  283. rate?: number;
  284. estimated?: number;
  285. upload?: boolean;
  286. download?: boolean;
  287. event?: BrowserProgressEvent;
  288. lengthComputable: boolean;
  289. }
  290. type Milliseconds = number;
  291. type AxiosAdapterName = StringLiteralsOrString<'xhr' | 'http' | 'fetch'>;
  292. type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
  293. export type AddressFamily = 4 | 6 | undefined;
  294. export interface LookupAddressEntry {
  295. address: string;
  296. family?: AddressFamily;
  297. }
  298. export type LookupAddress = string | LookupAddressEntry;
  299. export interface AxiosRequestConfig<D = any> {
  300. url?: string;
  301. method?: StringLiteralsOrString<Method>;
  302. baseURL?: string;
  303. allowAbsoluteUrls?: boolean;
  304. transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
  305. transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
  306. headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders;
  307. params?: any;
  308. paramsSerializer?: ParamsSerializerOptions | CustomParamsSerializer;
  309. data?: D;
  310. timeout?: Milliseconds;
  311. timeoutErrorMessage?: string;
  312. withCredentials?: boolean;
  313. adapter?: AxiosAdapterConfig | AxiosAdapterConfig[];
  314. auth?: AxiosBasicCredentials;
  315. responseType?: ResponseType;
  316. responseEncoding?: StringLiteralsOrString<responseEncoding>;
  317. xsrfCookieName?: string;
  318. xsrfHeaderName?: string;
  319. onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
  320. onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void;
  321. maxContentLength?: number;
  322. validateStatus?: ((status: number) => boolean) | null;
  323. maxBodyLength?: number;
  324. maxRedirects?: number;
  325. maxRate?: number | [MaxUploadRate, MaxDownloadRate];
  326. beforeRedirect?: (
  327. options: Record<string, any>,
  328. responseDetails: {
  329. headers: Record<string, string>;
  330. statusCode: HttpStatusCode;
  331. }
  332. ) => void;
  333. socketPath?: string | null;
  334. allowedSocketPaths?: string | string[] | null;
  335. transport?: any;
  336. httpAgent?: any;
  337. httpsAgent?: any;
  338. proxy?: AxiosProxyConfig | false;
  339. cancelToken?: CancelToken | undefined;
  340. decompress?: boolean;
  341. transitional?: TransitionalOptions;
  342. signal?: GenericAbortSignal;
  343. insecureHTTPParser?: boolean;
  344. env?: {
  345. FormData?: new (...args: any[]) => object;
  346. fetch?: (input: URL | Request | string, init?: RequestInit) => Promise<Response>;
  347. Request?: new (input: URL | Request | string, init?: RequestInit) => Request;
  348. Response?: new (
  349. body?: ArrayBuffer | ArrayBufferView | Blob | FormData | URLSearchParams | string | null,
  350. init?: ResponseInit
  351. ) => Response;
  352. };
  353. formSerializer?: FormSerializerOptions;
  354. family?: AddressFamily;
  355. lookup?:
  356. | ((
  357. hostname: string,
  358. options: object,
  359. cb: (
  360. err: Error | null,
  361. address: LookupAddress | LookupAddress[],
  362. family?: AddressFamily
  363. ) => void
  364. ) => void)
  365. | ((
  366. hostname: string,
  367. options: object
  368. ) => Promise<
  369. [address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress
  370. >);
  371. withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined);
  372. parseReviver?: (this: any, key: string, value: any) => any;
  373. fetchOptions?: Omit<RequestInit, 'body' | 'headers' | 'method' | 'signal'> | Record<string, any>;
  374. httpVersion?: 1 | 2;
  375. http2Options?: Record<string, any> & {
  376. sessionTimeout?: number;
  377. };
  378. }
  379. // Alias
  380. export type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;
  381. export interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig<D> {
  382. headers: AxiosRequestHeaders;
  383. }
  384. export interface HeadersDefaults {
  385. common: RawAxiosRequestHeaders;
  386. delete: RawAxiosRequestHeaders;
  387. get: RawAxiosRequestHeaders;
  388. head: RawAxiosRequestHeaders;
  389. post: RawAxiosRequestHeaders;
  390. put: RawAxiosRequestHeaders;
  391. patch: RawAxiosRequestHeaders;
  392. options?: RawAxiosRequestHeaders;
  393. purge?: RawAxiosRequestHeaders;
  394. link?: RawAxiosRequestHeaders;
  395. unlink?: RawAxiosRequestHeaders;
  396. }
  397. export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
  398. headers: HeadersDefaults;
  399. }
  400. export interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
  401. headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>;
  402. }
  403. export interface AxiosResponse<T = any, D = any, H = {}> {
  404. data: T;
  405. status: number;
  406. statusText: string;
  407. headers: (H & RawAxiosResponseHeaders) | AxiosResponseHeaders;
  408. config: InternalAxiosRequestConfig<D>;
  409. request?: any;
  410. }
  411. export class AxiosError<T = unknown, D = any> extends Error {
  412. constructor(
  413. message?: string,
  414. code?: string,
  415. config?: InternalAxiosRequestConfig<D>,
  416. request?: any,
  417. response?: AxiosResponse<T, D>
  418. );
  419. config?: InternalAxiosRequestConfig<D>;
  420. code?: string;
  421. request?: any;
  422. response?: AxiosResponse<T, D>;
  423. isAxiosError: boolean;
  424. status?: number;
  425. toJSON: () => object;
  426. cause?: Error;
  427. event?: BrowserProgressEvent;
  428. static from<T = unknown, D = any>(
  429. error: Error | unknown,
  430. code?: string,
  431. config?: InternalAxiosRequestConfig<D>,
  432. request?: any,
  433. response?: AxiosResponse<T, D>,
  434. customProps?: object
  435. ): AxiosError<T, D>;
  436. static readonly ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
  437. static readonly ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
  438. static readonly ERR_BAD_OPTION = 'ERR_BAD_OPTION';
  439. static readonly ERR_NETWORK = 'ERR_NETWORK';
  440. static readonly ERR_DEPRECATED = 'ERR_DEPRECATED';
  441. static readonly ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
  442. static readonly ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
  443. static readonly ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
  444. static readonly ERR_INVALID_URL = 'ERR_INVALID_URL';
  445. static readonly ERR_CANCELED = 'ERR_CANCELED';
  446. static readonly ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
  447. static readonly ECONNABORTED = 'ECONNABORTED';
  448. static readonly ETIMEDOUT = 'ETIMEDOUT';
  449. }
  450. export class CanceledError<T> extends AxiosError<T> {
  451. readonly name: 'CanceledError';
  452. }
  453. export type AxiosPromise<T = any> = Promise<AxiosResponse<T>>;
  454. export interface CancelStatic {
  455. new (message?: string): Cancel;
  456. }
  457. export interface Cancel {
  458. message: string | undefined;
  459. }
  460. export interface Canceler {
  461. (message?: string, config?: AxiosRequestConfig, request?: any): void;
  462. }
  463. export interface CancelTokenStatic {
  464. new (executor: (cancel: Canceler) => void): CancelToken;
  465. source(): CancelTokenSource;
  466. }
  467. export interface CancelToken {
  468. promise: Promise<Cancel>;
  469. reason?: Cancel;
  470. throwIfRequested(): void;
  471. }
  472. export interface CancelTokenSource {
  473. token: CancelToken;
  474. cancel: Canceler;
  475. }
  476. export interface AxiosInterceptorOptions {
  477. synchronous?: boolean;
  478. runWhen?: ((config: InternalAxiosRequestConfig) => boolean) | null;
  479. }
  480. type AxiosInterceptorFulfilled<T> = (value: T) => T | Promise<T>;
  481. type AxiosInterceptorRejected = (error: any) => any;
  482. type AxiosRequestInterceptorUse<T> = (
  483. onFulfilled?: AxiosInterceptorFulfilled<T> | null,
  484. onRejected?: AxiosInterceptorRejected | null,
  485. options?: AxiosInterceptorOptions
  486. ) => number;
  487. type AxiosResponseInterceptorUse<T> = (
  488. onFulfilled?: AxiosInterceptorFulfilled<T> | null,
  489. onRejected?: AxiosInterceptorRejected | null
  490. ) => number;
  491. interface AxiosInterceptorHandler<T> {
  492. fulfilled: AxiosInterceptorFulfilled<T>;
  493. rejected?: AxiosInterceptorRejected;
  494. synchronous: boolean;
  495. runWhen?: ((config: InternalAxiosRequestConfig) => boolean) | null;
  496. }
  497. export interface AxiosInterceptorManager<V> {
  498. use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
  499. eject(id: number): void;
  500. clear(): void;
  501. handlers?: Array<AxiosInterceptorHandler<V>>;
  502. }
  503. export class Axios {
  504. constructor(config?: AxiosRequestConfig);
  505. defaults: AxiosDefaults;
  506. interceptors: {
  507. request: AxiosInterceptorManager<InternalAxiosRequestConfig>;
  508. response: AxiosInterceptorManager<AxiosResponse>;
  509. };
  510. getUri(config?: AxiosRequestConfig): string;
  511. request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
  512. get<T = any, R = AxiosResponse<T>, D = any>(
  513. url: string,
  514. config?: AxiosRequestConfig<D>
  515. ): Promise<R>;
  516. delete<T = any, R = AxiosResponse<T>, D = any>(
  517. url: string,
  518. config?: AxiosRequestConfig<D>
  519. ): Promise<R>;
  520. head<T = any, R = AxiosResponse<T>, D = any>(
  521. url: string,
  522. config?: AxiosRequestConfig<D>
  523. ): Promise<R>;
  524. options<T = any, R = AxiosResponse<T>, D = any>(
  525. url: string,
  526. config?: AxiosRequestConfig<D>
  527. ): Promise<R>;
  528. post<T = any, R = AxiosResponse<T>, D = any>(
  529. url: string,
  530. data?: D,
  531. config?: AxiosRequestConfig<D>
  532. ): Promise<R>;
  533. put<T = any, R = AxiosResponse<T>, D = any>(
  534. url: string,
  535. data?: D,
  536. config?: AxiosRequestConfig<D>
  537. ): Promise<R>;
  538. patch<T = any, R = AxiosResponse<T>, D = any>(
  539. url: string,
  540. data?: D,
  541. config?: AxiosRequestConfig<D>
  542. ): Promise<R>;
  543. postForm<T = any, R = AxiosResponse<T>, D = any>(
  544. url: string,
  545. data?: D,
  546. config?: AxiosRequestConfig<D>
  547. ): Promise<R>;
  548. putForm<T = any, R = AxiosResponse<T>, D = any>(
  549. url: string,
  550. data?: D,
  551. config?: AxiosRequestConfig<D>
  552. ): Promise<R>;
  553. patchForm<T = any, R = AxiosResponse<T>, D = any>(
  554. url: string,
  555. data?: D,
  556. config?: AxiosRequestConfig<D>
  557. ): Promise<R>;
  558. }
  559. export interface AxiosInstance extends Axios {
  560. <T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
  561. <T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
  562. create(config?: CreateAxiosDefaults): AxiosInstance;
  563. defaults: Omit<AxiosDefaults, 'headers'> & {
  564. headers: HeadersDefaults & {
  565. [key: string]: AxiosHeaderValue;
  566. };
  567. };
  568. }
  569. export interface GenericFormData {
  570. append(name: string, value: any, options?: any): any;
  571. }
  572. export interface GenericHTMLFormElement {
  573. name: string;
  574. method: string;
  575. submit(): void;
  576. }
  577. export function getAdapter(
  578. adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined
  579. ): AxiosAdapter;
  580. export function toFormData(
  581. sourceObj: object,
  582. targetFormData?: GenericFormData,
  583. options?: FormSerializerOptions
  584. ): GenericFormData;
  585. export function formToJSON(form: GenericFormData | GenericHTMLFormElement): object;
  586. export function isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>;
  587. export function spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
  588. export function isCancel<T = any>(value: any): value is CanceledError<T>;
  589. export function all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
  590. export function mergeConfig<D = any>(
  591. config1: AxiosRequestConfig<D>,
  592. config2: AxiosRequestConfig<D>
  593. ): AxiosRequestConfig<D>;
  594. export interface AxiosStatic extends AxiosInstance {
  595. Cancel: CancelStatic;
  596. CancelToken: CancelTokenStatic;
  597. Axios: typeof Axios;
  598. AxiosError: typeof AxiosError;
  599. HttpStatusCode: typeof HttpStatusCode;
  600. readonly VERSION: string;
  601. isCancel: typeof isCancel;
  602. all: typeof all;
  603. spread: typeof spread;
  604. isAxiosError: typeof isAxiosError;
  605. toFormData: typeof toFormData;
  606. formToJSON: typeof formToJSON;
  607. getAdapter: typeof getAdapter;
  608. CanceledError: typeof CanceledError;
  609. AxiosHeaders: typeof AxiosHeaders;
  610. mergeConfig: typeof mergeConfig;
  611. }
  612. declare const axios: AxiosStatic;
  613. export default axios;