@whitesev/utils 1.5.4 → 1.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1504,13 +1504,14 @@ class Httpx {
1504
1504
  },
1505
1505
  /**
1506
1506
  * 成功的回调
1507
- * @param response
1507
+ * @param response 响应
1508
+ * @param details 请求的配置
1508
1509
  */
1509
- successResponseCallBack(response) {
1510
+ successResponseCallBack(response, details) {
1510
1511
  for (let index = 0; index < this.$config.configList.length; index++) {
1511
1512
  let item = this.$config.configList[index];
1512
1513
  if (typeof item.successFn === "function") {
1513
- if (item.successFn(response) == null) {
1514
+ if (item.successFn(response, details) == null) {
1514
1515
  return;
1515
1516
  }
1516
1517
  }
@@ -1519,7 +1520,7 @@ class Httpx {
1519
1520
  },
1520
1521
  /**
1521
1522
  * 失败的回调
1522
- * @param response
1523
+ * @param data 配置
1523
1524
  */
1524
1525
  errorResponseCallBack(data) {
1525
1526
  for (let index = 0; index < this.$config.configList.length; index++) {
@@ -1782,6 +1783,7 @@ class Httpx {
1782
1783
  type: "onabort",
1783
1784
  error: new TypeError("request canceled"),
1784
1785
  response: null,
1786
+ details: details,
1785
1787
  }) == null) {
1786
1788
  return;
1787
1789
  }
@@ -1813,6 +1815,7 @@ class Httpx {
1813
1815
  type: "onerror",
1814
1816
  error: new TypeError("request error"),
1815
1817
  response: response,
1818
+ details: details,
1816
1819
  }) == null) {
1817
1820
  return;
1818
1821
  }
@@ -1841,6 +1844,7 @@ class Httpx {
1841
1844
  type: "ontimeout",
1842
1845
  error: new TypeError("request timeout"),
1843
1846
  response: (argumentsList || [null])[0],
1847
+ details: details,
1844
1848
  }) == null) {
1845
1849
  return;
1846
1850
  }
@@ -1924,8 +1928,7 @@ class Httpx {
1924
1928
  }
1925
1929
  /* 状态码2xx都是成功的 */
1926
1930
  if (Math.floor(Response.status / 100) === 2) {
1927
- if (this.context.HttpxResponseHook.successResponseCallBack(Response) ==
1928
- null) {
1931
+ if (this.context.HttpxResponseHook.successResponseCallBack(Response, details) == null) {
1929
1932
  return;
1930
1933
  }
1931
1934
  resolve({
@@ -2046,7 +2049,7 @@ class Httpx {
2046
2049
  let responseText = "";
2047
2050
  /** 响应xml文档 */
2048
2051
  let responseXML = "";
2049
- let arrayBuffer = await resp.arrayBuffer;
2052
+ let arrayBuffer = await resp.arrayBuffer();
2050
2053
  let encoding = "utf-8";
2051
2054
  if (resp.headers.has("Content-Type")) {
2052
2055
  let charsetMatched = resp.headers
@@ -2057,7 +2060,7 @@ class Httpx {
2057
2060
  }
2058
2061
  }
2059
2062
  let textDecoder = new TextDecoder(encoding);
2060
- responseText = textDecoder.decode(await resp.arrayBuffer());
2063
+ responseText = textDecoder.decode(arrayBuffer);
2061
2064
  response = responseText;
2062
2065
  if (details.responseType === "arraybuffer") {
2063
2066
  response = arrayBuffer;