@seayoo-web/request 1.0.0 → 1.0.2
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/README.md +6 -6
- package/dist/inc/type.d.ts +2 -2
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -209,13 +209,13 @@ setConfig({ timeout: 5000 })
|
|
|
209
209
|
|
|
210
210
|
### requestHandler
|
|
211
211
|
|
|
212
|
-
类型:null | ((headers: Record<string, string>,
|
|
212
|
+
类型:null | ((headers: Record<string, string>, params: Record<string, string>, method: string, url: string) => MaybePromise<void | string>)
|
|
213
213
|
|
|
214
|
-
|
|
214
|
+
说明:同时兼具 transformer 的功能,可用于发送前修改请求相关数据
|
|
215
215
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
- 发送前用于修改 headers 或 params 的函数,headers 和 params 为引用数据,可以直接修改或追加内容;
|
|
217
|
+
- 函数如果返回一个非空字符串,则当作 url 地址使用,原有的 url 地址将被替换;
|
|
218
|
+
- 通常用于全局追加 header 自定义认证信息;
|
|
219
219
|
|
|
220
220
|
### errorHandler
|
|
221
221
|
|
|
@@ -227,7 +227,7 @@ setConfig({ timeout: 5000 })
|
|
|
227
227
|
|
|
228
228
|
类型:null | ((result: IResponseResult, method: string, url: string) => void)
|
|
229
229
|
|
|
230
|
-
|
|
230
|
+
说明:请求完成后用于统一检查响应结果,非网络错误时触发,入参的数据均为副本,仅仅可读
|
|
231
231
|
|
|
232
232
|
### messageHandler
|
|
233
233
|
|
package/dist/inc/type.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MaybePromise } from "@seayoo-web/utils";
|
|
1
|
+
import type { MaybePromise } from "@seayoo-web/utils";
|
|
2
2
|
import type { RequestGlobalConfig } from "./config";
|
|
3
3
|
export type IBaseRequestBody = Blob | ArrayBuffer | FormData | URLSearchParams | string;
|
|
4
4
|
/** 通用网络请求工具的基本配置 */
|
|
@@ -109,7 +109,7 @@ export interface IRequestBaseResponse {
|
|
|
109
109
|
statusText: string;
|
|
110
110
|
/** 响应头,如果网络错误,则返回空对象 */
|
|
111
111
|
headers?: Record<string, string | undefined>;
|
|
112
|
-
/**
|
|
112
|
+
/** 响应体,如果网络错误或 204/202,则返回空或错误信息 */
|
|
113
113
|
body: string;
|
|
114
114
|
}
|
|
115
115
|
/** 对外工具接口的返回内容 */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seayoo-web/request",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "requst tools for seayoo web",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -47,19 +47,19 @@
|
|
|
47
47
|
"commit-msg": "node scripts/verifyCommit.mjs $1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@types/node": "^20.
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
52
|
-
"@typescript-eslint/parser": "^6.
|
|
53
|
-
"eslint": "^8.
|
|
50
|
+
"@types/node": "^20.9.0",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^6.10.0",
|
|
52
|
+
"@typescript-eslint/parser": "^6.10.0",
|
|
53
|
+
"eslint": "^8.53.0",
|
|
54
54
|
"eslint-config-prettier": "^9.0.0",
|
|
55
|
-
"eslint-plugin-prettier": "^5.0.
|
|
55
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
56
56
|
"lint-staged": "^14.0.1",
|
|
57
57
|
"microbundle": "^0.15.1",
|
|
58
|
-
"rimraf": "^5.0.
|
|
58
|
+
"rimraf": "^5.0.5",
|
|
59
59
|
"simple-git-hooks": "^2.9.0",
|
|
60
60
|
"typescript": "^5.2.2"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@seayoo-web/utils": "^1.
|
|
63
|
+
"@seayoo-web/utils": "^1.8.0"
|
|
64
64
|
}
|
|
65
65
|
}
|