uniapp-request-sdk 1.3.6 → 1.3.8
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.d.ts +1 -1
- package/dist/index.esm.js +3 -15
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ interface IParams {
|
|
|
22
22
|
/** 传入的token前缀,默认Bearer ,注意Bearer有个空字符串*/
|
|
23
23
|
tokenPrefix?: string;
|
|
24
24
|
/** 自定义得到token的函数,默认使用从客户端获取token的方式 */
|
|
25
|
-
getTokenFun
|
|
25
|
+
getTokenFun?: () => Promise<string>;
|
|
26
26
|
}
|
|
27
27
|
declare class UniRequest {
|
|
28
28
|
/** 基准路径 */
|
package/dist/index.esm.js
CHANGED
|
@@ -20,20 +20,6 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
20
20
|
});
|
|
21
21
|
return Constructor;
|
|
22
22
|
}
|
|
23
|
-
function _defineProperty(obj, key, value) {
|
|
24
|
-
key = _toPropertyKey(key);
|
|
25
|
-
if (key in obj) {
|
|
26
|
-
Object.defineProperty(obj, key, {
|
|
27
|
-
value: value,
|
|
28
|
-
enumerable: true,
|
|
29
|
-
configurable: true,
|
|
30
|
-
writable: true
|
|
31
|
-
});
|
|
32
|
-
} else {
|
|
33
|
-
obj[key] = value;
|
|
34
|
-
}
|
|
35
|
-
return obj;
|
|
36
|
-
}
|
|
37
23
|
function _toPrimitive(input, hint) {
|
|
38
24
|
if (typeof input !== "object" || input === null) return input;
|
|
39
25
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -124,11 +110,13 @@ var UniRequest = /*#__PURE__*/function () {
|
|
|
124
110
|
} else {
|
|
125
111
|
url = "".concat(params.url, "?t=").concat(Date.now());
|
|
126
112
|
}
|
|
127
|
-
var header = Object.assign(Object.assign(
|
|
113
|
+
var header = Object.assign(Object.assign({}, this.header), params.header);
|
|
128
114
|
var requestedToken = false;
|
|
129
115
|
var retryCount = 0;
|
|
130
116
|
return new Promise(function (res, rej) {
|
|
131
117
|
var retryFucntion = function retryFucntion() {
|
|
118
|
+
/** 因为token需要动态获取,因此放入这里 */
|
|
119
|
+
header[_this3.tokenHeader] = "".concat(_this3.tokenPrefix).concat(_this3.token);
|
|
132
120
|
requestPromise(Object.assign(Object.assign({}, params), {
|
|
133
121
|
header: header,
|
|
134
122
|
url: url,
|