uniapp-request-sdk 1.3.7 → 1.3.9
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 +5 -16
- package/package.json +1 -1
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,
|
|
@@ -147,7 +135,8 @@ var UniRequest = /*#__PURE__*/function () {
|
|
|
147
135
|
(_this3.getTokenFun ? _this3.getTokenFun() : getToken(_this3.tokenEventName)).then(function (token) {
|
|
148
136
|
_this3.token = token;
|
|
149
137
|
requestedToken = true;
|
|
150
|
-
|
|
138
|
+
/** 获取token应该立马请求,不需要延迟 */
|
|
139
|
+
retryFucntion();
|
|
151
140
|
})["catch"](function () {
|
|
152
141
|
if (_this3.maxRetryCount > retryCount) {
|
|
153
142
|
delayRetryFcuntion();
|