uniapp-request-sdk 1.0.1 → 1.0.3

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.
Files changed (2) hide show
  1. package/dist/index.d.ts +8 -8
  2. package/package.json +1 -2
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  interface IParams {
4
4
  /** baseUrl,代理的path也需要填入,比如https://hostname/proxy/ */
5
- baseUrl: string;
5
+ baseUrl?: string;
6
6
  /** 公共错误处理函数 */
7
7
  onErrorHandler?: (error: any) => void;
8
8
  /** 公共请求头 */
@@ -14,7 +14,7 @@ interface IParams {
14
14
  /** 请求尝试延迟时间 */
15
15
  retryDelay?: number;
16
16
  /** token */
17
- token: string;
17
+ token?: string;
18
18
  /** 向APP得到token的event事件名称,默认getToken */
19
19
  tokenEventName?: string;
20
20
  }
@@ -34,12 +34,12 @@ declare class UniRequest {
34
34
  constructor(params?: IParams);
35
35
  private rejectHandler;
36
36
  setParams(params?: IParams): void;
37
- request(params: {
37
+ request<T>(params: {
38
38
  url: string;
39
39
  method: RequestOptions['method'];
40
40
  data?: RequestOptions['data'];
41
41
  header?: RequestOptions['header'];
42
- } & RequestOptions): Promise<unknown>;
42
+ } & RequestOptions): Promise<T>;
43
43
  /**
44
44
  * post请求
45
45
  * @param url
@@ -47,10 +47,10 @@ declare class UniRequest {
47
47
  * @param header
48
48
  * @returns
49
49
  */
50
- post(url: string, data?: {}, header?: Record<string, string>): Promise<unknown>;
51
- get(url: string, data?: {}, header?: Record<string, string>): Promise<unknown>;
52
- delete(url: string, data?: {}, header?: Record<string, string>): Promise<unknown>;
53
- put(url: string, data?: {}, header?: Record<string, string>): Promise<unknown>;
50
+ post<T>(url: string, data?: {}, header?: Record<string, string>): Promise<T>;
51
+ get<T>(url: string, data?: {}, header?: Record<string, string>): Promise<T>;
52
+ delete<T>(url: string, data?: {}, header?: Record<string, string>): Promise<T>;
53
+ put<T>(url: string, data?: {}, header?: Record<string, string>): Promise<T>;
54
54
  }
55
55
 
56
56
  export { IParams, UniRequest as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uniapp-request-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "用于uniapp小程序的请求库的sdk",
5
5
  "main": "dist/index.umd.mini.js",
6
6
  "typings": "dist/index.d.ts",
@@ -12,7 +12,6 @@
12
12
  "dev": "rimraf dist typings && tsc --emitDeclarationOnly && cross-env NODE_ENV=development rollup -c --watch",
13
13
  "build": "rimraf dist typings && tsc --emitDeclarationOnly && cross-env NODE_ENV=production rollup -c",
14
14
  "prepublish": "npm run build",
15
- "postinstall": "patch-package",
16
15
  "c": "git-cz"
17
16
  },
18
17
  "author": "yaojun",