uniapp-request-sdk 1.3.5 → 1.3.7

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 CHANGED
@@ -21,6 +21,8 @@ interface IParams {
21
21
  tokenHeader?: string;
22
22
  /** 传入的token前缀,默认Bearer ,注意Bearer有个空字符串*/
23
23
  tokenPrefix?: string;
24
+ /** 自定义得到token的函数,默认使用从客户端获取token的方式 */
25
+ getTokenFun?: () => Promise<string>;
24
26
  }
25
27
  declare class UniRequest {
26
28
  /** 基准路径 */
@@ -39,6 +41,8 @@ declare class UniRequest {
39
41
  private tokenHeader;
40
42
  /** 传入的token前缀,默认Bearer ,注意Bearer有个空字符串*/
41
43
  private tokenPrefix;
44
+ /** 自定义得到token的函数 */
45
+ private getTokenFun?;
42
46
  constructor(params?: IParams);
43
47
  private rejectHandler;
44
48
  setParams(params?: IParams): void;
package/dist/index.esm.js CHANGED
@@ -144,7 +144,7 @@ var UniRequest = /*#__PURE__*/function () {
144
144
  }
145
145
  } else if (statusCode === 403 && !requestedToken) {
146
146
  // #ifndef H5
147
- getToken(_this3.tokenEventName).then(function (token) {
147
+ (_this3.getTokenFun ? _this3.getTokenFun() : getToken(_this3.tokenEventName)).then(function (token) {
148
148
  _this3.token = token;
149
149
  requestedToken = true;
150
150
  delayRetryFcuntion();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uniapp-request-sdk",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "用于uniapp小程序的请求库的sdk",
5
5
  "main": "dist/index.esm.js",
6
6
  "typings": "dist/index.d.ts",