@swiftcrab/request 1.0.1 → 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.
Files changed (2) hide show
  1. package/README.md +10 -8
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  - 安装: pnpm add @swiftcrab/request
4
4
 
5
- #### 创建 request.ts
5
+ #### 创建 overFetch.ts
6
6
 
7
7
  ```typescript
8
8
  import {
@@ -20,17 +20,19 @@ function createRequestClient(baseURL: string) {
20
20
  baseURL,
21
21
  })
22
22
 
23
- /** 处理重新认证 */
24
- async function doReAuthenticate() {
25
- message.error('Access token or refresh token is invalid or expired. ')
26
- }
23
+ /** 处理重新认证,常用于回到登录页 */
24
+ async function doReAuthenticate() {}
27
25
 
28
26
  /** 处理刷新令牌 */
29
- async function doRefreshToken() {}
27
+ async function doRefreshToken() {
28
+ return ''
29
+ }
30
30
 
31
31
  // 处理请求头处理
32
32
  client.addRequestInterceptor({
33
- fulfilled: config => {},
33
+ fulfilled: config => {
34
+ return config
35
+ },
34
36
  })
35
37
 
36
38
  // 返回数据格式 { data: any, info: { code: number, message: string, status: boolean } }
@@ -41,7 +43,7 @@ function createRequestClient(baseURL: string) {
41
43
  /** 响应数据中装载实际数据的字段名,或者提供一个函数从响应数据中解析需要返回的数据 */
42
44
  dataField: 'data',
43
45
  /** 当codeField所指定的字段值与successCode相同时,代表接口访问成功。如果提供一个函数,则返回true代表接口访问成功 */
44
- successCode: [200],
46
+ successCode: 200,
45
47
  }),
46
48
  )
47
49
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swiftcrab/request",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -21,7 +21,7 @@
21
21
  "devDependencies": {
22
22
  "unbuild": "^3.5.0",
23
23
  "typescript": "^5.8.3",
24
- "@swiftcrab/tsconfig": "1.0.0"
24
+ "@swiftcrab/tsconfig": "1.0.1"
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public",