@jetlinks-web/core 2.0.1 → 2.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.
- package/package.json +3 -3
- package/src/axios.ts +6 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jetlinks-web/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"module": "index.ts",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"axios": "^1.7.4",
|
|
19
|
-
"@jetlinks-web/constants": "^1.0.2",
|
|
20
19
|
"@jetlinks-web/types": "^1.0.2",
|
|
21
|
-
"@jetlinks-web/utils": "^1.
|
|
20
|
+
"@jetlinks-web/utils": "^1.2.2",
|
|
21
|
+
"@jetlinks-web/constants": "^1.0.5"
|
|
22
22
|
},
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"registry": "https://registry.npmjs.org/",
|
package/src/axios.ts
CHANGED
|
@@ -59,7 +59,9 @@ const handleRequest = (config: InternalAxiosRequestConfig) => {
|
|
|
59
59
|
return config
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
config.headers[TOKEN_KEY]
|
|
62
|
+
if (!config.headers[TOKEN_KEY]) {
|
|
63
|
+
config.headers[TOKEN_KEY] = token
|
|
64
|
+
}
|
|
63
65
|
|
|
64
66
|
if (_options.requestOptions && isFunction(_options.requestOptions)) {
|
|
65
67
|
const extraOptions = _options.requestOptions(config)
|
|
@@ -150,7 +152,7 @@ export const crateAxios = (options: Options) => {
|
|
|
150
152
|
)
|
|
151
153
|
}
|
|
152
154
|
|
|
153
|
-
export const post = <T = any>(url: string, data: any =
|
|
155
|
+
export const post = <T = any>(url: string, data: any = {}, ext?: any) => {
|
|
154
156
|
return (instance<any, AxiosResponseRewrite<T>>({
|
|
155
157
|
method: 'POST',
|
|
156
158
|
url,
|
|
@@ -168,7 +170,7 @@ export const get = <T = any>(url: string, params: any = undefined, ext?: any) =>
|
|
|
168
170
|
})
|
|
169
171
|
}
|
|
170
172
|
|
|
171
|
-
export const put = <T = any>(url: string, data: any =
|
|
173
|
+
export const put = <T = any>(url: string, data: any = {}, ext?: any) => {
|
|
172
174
|
return instance<any, AxiosResponseRewrite<T>>({
|
|
173
175
|
method: 'PUT',
|
|
174
176
|
url,
|
|
@@ -177,7 +179,7 @@ export const put = <T = any>(url: string, data: any = undefined, ext?: any) => {
|
|
|
177
179
|
})
|
|
178
180
|
}
|
|
179
181
|
|
|
180
|
-
export const patch = <T = any>(url: string, data: any =
|
|
182
|
+
export const patch = <T = any>(url: string, data: any = {}, ext?: any) => {
|
|
181
183
|
return instance<any, AxiosResponseRewrite<T>>({
|
|
182
184
|
method: 'patch',
|
|
183
185
|
url,
|