index.d.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. export interface AxiosTransformer {
  2. (data: any): any;
  3. }
  4. export interface AxiosAdapter {
  5. (config: AxiosRequestConfig): AxiosPromise;
  6. }
  7. export interface AxiosBasicCredentials {
  8. username: string;
  9. password: string;
  10. }
  11. export interface AxiosProxyConfig {
  12. host: string;
  13. port: number;
  14. }
  15. export interface AxiosRequestConfig {
  16. url?: string;
  17. method?: string;
  18. baseURL?: string;
  19. transformRequest?: AxiosTransformer | AxiosTransformer[];
  20. transformResponse?: AxiosTransformer | AxiosTransformer[];
  21. headers?: any;
  22. params?: any;
  23. paramsSerializer?: (params: any) => string;
  24. data?: any;
  25. timeout?: number;
  26. withCredentials?: boolean;
  27. adapter?: AxiosAdapter;
  28. auth?: AxiosBasicCredentials;
  29. responseType?: string;
  30. xsrfCookieName?: string;
  31. xsrfHeaderName?: string;
  32. onUploadProgress?: (progressEvent: any) => void;
  33. onDownloadProgress?: (progressEvent: any) => void;
  34. maxContentLength?: number;
  35. validateStatus?: (status: number) => boolean;
  36. maxRedirects?: number;
  37. httpAgent?: any;
  38. httpsAgent?: any;
  39. proxy?: AxiosProxyConfig;
  40. cancelToken?: CancelToken;
  41. }
  42. export interface AxiosResponse {
  43. data: any;
  44. status: number;
  45. statusText: string;
  46. headers: any;
  47. config: AxiosRequestConfig;
  48. }
  49. export interface AxiosError extends Error {
  50. config: AxiosRequestConfig;
  51. code?: string;
  52. response?: AxiosResponse;
  53. }
  54. export interface AxiosPromise extends Promise<AxiosResponse> {
  55. }
  56. export interface CancelStatic {
  57. new (message?: string): Cancel;
  58. }
  59. export interface Cancel {
  60. message: string;
  61. }
  62. export interface Canceler {
  63. (message?: string): void;
  64. }
  65. export interface CancelTokenStatic {
  66. new (executor: (cancel: Canceler) => void): CancelToken;
  67. source(): CancelTokenSource;
  68. }
  69. export interface CancelToken {
  70. promise: Promise<Cancel>;
  71. reason?: Cancel;
  72. throwIfRequested(): void;
  73. }
  74. export interface CancelTokenSource {
  75. token: CancelToken;
  76. cancel: Canceler;
  77. }
  78. export interface AxiosInterceptorManager<V> {
  79. use(onFulfilled: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number;
  80. eject(id: number): void;
  81. }
  82. export interface AxiosInstance {
  83. defaults: AxiosRequestConfig;
  84. interceptors: {
  85. request: AxiosInterceptorManager<AxiosRequestConfig>;
  86. response: AxiosInterceptorManager<AxiosResponse>;
  87. };
  88. request(config: AxiosRequestConfig): AxiosPromise;
  89. get(url: string, config?: AxiosRequestConfig): AxiosPromise;
  90. delete(url: string, config?: AxiosRequestConfig): AxiosPromise;
  91. head(url: string, config?: AxiosRequestConfig): AxiosPromise;
  92. post(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise;
  93. put(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise;
  94. patch(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise;
  95. }
  96. export interface AxiosStatic extends AxiosInstance {
  97. (config: AxiosRequestConfig): AxiosPromise;
  98. (url: string, config?: AxiosRequestConfig): AxiosPromise;
  99. create(config?: AxiosRequestConfig): AxiosInstance;
  100. Cancel: CancelStatic;
  101. CancelToken: CancelTokenStatic;
  102. isCancel(value: any): boolean;
  103. all<T>(values: (T | Promise<T>)[]): Promise<T[]>;
  104. spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
  105. }
  106. declare const Axios: AxiosStatic;
  107. export default Axios;