620965ce85679fc181bf864c4d9c24d33f1ecaba231531fb6aa9cb8f885465c8aa97c9e3ad79d8f0b0f99744c5c31f6477d788846c3b1e8632782243c2cf20 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import { AjaxRequest, AjaxResponseType } from './types';
  2. /**
  3. * A normalized response from an AJAX request. To get the data from the response,
  4. * you will want to read the `response` property.
  5. *
  6. * - DO NOT create instances of this class directly.
  7. * - DO NOT subclass this class.
  8. *
  9. * It is advised not to hold this object in memory, as it has a reference to
  10. * the original XHR used to make the request, as well as properties containing
  11. * request and response data.
  12. *
  13. * @see {@link ajax}
  14. * @see {@link AjaxConfig}
  15. */
  16. export declare class AjaxResponse<T> {
  17. /**
  18. * The original event object from the raw XHR event.
  19. */
  20. readonly originalEvent: ProgressEvent;
  21. /**
  22. * The XMLHttpRequest object used to make the request.
  23. * NOTE: It is advised not to hold this in memory, as it will retain references to all of it's event handlers
  24. * and many other things related to the request.
  25. */
  26. readonly xhr: XMLHttpRequest;
  27. /**
  28. * The request parameters used to make the HTTP request.
  29. */
  30. readonly request: AjaxRequest;
  31. /**
  32. * The event type. This can be used to discern between different events
  33. * if you're using progress events with {@link includeDownloadProgress} or
  34. * {@link includeUploadProgress} settings in {@link AjaxConfig}.
  35. *
  36. * The event type consists of two parts: the {@link AjaxDirection} and the
  37. * the event type. Merged with `_`, they form the `type` string. The
  38. * direction can be an `upload` or a `download` direction, while an event can
  39. * be `loadstart`, `progress` or `load`.
  40. *
  41. * `download_load` is the type of event when download has finished and the
  42. * response is available.
  43. */
  44. readonly type: AjaxResponseType;
  45. /** The HTTP status code */
  46. readonly status: number;
  47. /**
  48. * The response data, if any. Note that this will automatically be converted to the proper type
  49. */
  50. readonly response: T;
  51. /**
  52. * The responseType set on the request. (For example: `""`, `"arraybuffer"`, `"blob"`, `"document"`, `"json"`, or `"text"`)
  53. * @deprecated There isn't much reason to examine this. It's the same responseType set (or defaulted) on the ajax config.
  54. * If you really need to examine this value, you can check it on the `request` or the `xhr`. Will be removed in v8.
  55. */
  56. readonly responseType: XMLHttpRequestResponseType;
  57. /**
  58. * The total number of bytes loaded so far. To be used with {@link total} while
  59. * calculating progress. (You will want to set {@link includeDownloadProgress} or
  60. * {@link includeDownloadProgress})
  61. */
  62. readonly loaded: number;
  63. /**
  64. * The total number of bytes to be loaded. To be used with {@link loaded} while
  65. * calculating progress. (You will want to set {@link includeDownloadProgress} or
  66. * {@link includeDownloadProgress})
  67. */
  68. readonly total: number;
  69. /**
  70. * A dictionary of the response headers.
  71. */
  72. readonly responseHeaders: Record<string, string>;
  73. /**
  74. * A normalized response from an AJAX request. To get the data from the response,
  75. * you will want to read the `response` property.
  76. *
  77. * - DO NOT create instances of this class directly.
  78. * - DO NOT subclass this class.
  79. *
  80. * @param originalEvent The original event object from the XHR `onload` event.
  81. * @param xhr The `XMLHttpRequest` object used to make the request. This is useful for examining status code, etc.
  82. * @param request The request settings used to make the HTTP request.
  83. * @param type The type of the event emitted by the {@link ajax} Observable
  84. */
  85. constructor(
  86. /**
  87. * The original event object from the raw XHR event.
  88. */
  89. originalEvent: ProgressEvent,
  90. /**
  91. * The XMLHttpRequest object used to make the request.
  92. * NOTE: It is advised not to hold this in memory, as it will retain references to all of it's event handlers
  93. * and many other things related to the request.
  94. */
  95. xhr: XMLHttpRequest,
  96. /**
  97. * The request parameters used to make the HTTP request.
  98. */
  99. request: AjaxRequest,
  100. /**
  101. * The event type. This can be used to discern between different events
  102. * if you're using progress events with {@link includeDownloadProgress} or
  103. * {@link includeUploadProgress} settings in {@link AjaxConfig}.
  104. *
  105. * The event type consists of two parts: the {@link AjaxDirection} and the
  106. * the event type. Merged with `_`, they form the `type` string. The
  107. * direction can be an `upload` or a `download` direction, while an event can
  108. * be `loadstart`, `progress` or `load`.
  109. *
  110. * `download_load` is the type of event when download has finished and the
  111. * response is available.
  112. */
  113. type?: AjaxResponseType);
  114. }
  115. //# sourceMappingURL=AjaxResponse.d.ts.map