nuxt-custom-fetch 2.3.0 → 2.3.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 +1 -0
- package/dist/module.d.mts +2 -1
- package/dist/module.json +2 -2
- package/dist/runtime/ajax.js +32 -42
- package/dist/types.d.mts +3 -1
- package/package.json +13 -14
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -7
- package/dist/types.d.ts +0 -1
package/README.md
CHANGED
package/dist/module.d.mts
CHANGED
package/dist/module.json
CHANGED
package/dist/runtime/ajax.js
CHANGED
|
@@ -69,9 +69,15 @@ export class CustomFetch {
|
|
|
69
69
|
Object.assign(config, this.baseConfig(config));
|
|
70
70
|
const generateOptionSegmentsWithConfig = generateOptionSegments(config);
|
|
71
71
|
if (this.showLogs && import.meta.client) {
|
|
72
|
-
|
|
72
|
+
let bodyLogs;
|
|
73
|
+
try {
|
|
74
|
+
bodyLogs = serialize(config.body);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.warn("[Custom Fetch] couldn't serialize `Body:`", error);
|
|
77
|
+
}
|
|
78
|
+
console.warn("[Custom Fetch] `Request:`", url, " `Query:`", serialize(generateOptionSegmentsWithConfig), " `Body:`", bodyLogs);
|
|
73
79
|
}
|
|
74
|
-
const { onRequest, onRequestError, onResponse, onResponseError, offline, handler, useHandler, immutableKey, ...restAjaxConfig } = config;
|
|
80
|
+
const { onRequest, onRequestError, onResponse, onResponseError, offline, handler, useHandler, showLogs, immutableKey, ...restAjaxConfig } = config;
|
|
75
81
|
if (import.meta.client && navigator && !navigator.onLine) {
|
|
76
82
|
if (offline) {
|
|
77
83
|
offline();
|
|
@@ -80,53 +86,37 @@ export class CustomFetch {
|
|
|
80
86
|
const interceptors = this.interceptors;
|
|
81
87
|
const _config = reactive({ ...restAjaxConfig });
|
|
82
88
|
const defaultOptions = {
|
|
83
|
-
onRequest(ctx) {
|
|
84
|
-
[interceptors.onRequest, onRequest].
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
fns?.(ctx);
|
|
89
|
+
async onRequest(ctx) {
|
|
90
|
+
const allFns = [interceptors.onRequest, onRequest].flat();
|
|
91
|
+
for (const fn of allFns) {
|
|
92
|
+
if (fn) {
|
|
93
|
+
await fn(ctx);
|
|
89
94
|
}
|
|
90
|
-
}
|
|
95
|
+
}
|
|
91
96
|
},
|
|
92
|
-
onRequestError(ctx) {
|
|
93
|
-
[interceptors.onRequestError, onRequestError].
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
fns?.(ctx);
|
|
97
|
+
async onRequestError(ctx) {
|
|
98
|
+
const allFns = [interceptors.onRequestError, onRequestError].flat();
|
|
99
|
+
for (const fn of allFns) {
|
|
100
|
+
if (fn) {
|
|
101
|
+
await fn(ctx);
|
|
98
102
|
}
|
|
99
|
-
}
|
|
100
|
-
throw createError({
|
|
101
|
-
statusCode: 400,
|
|
102
|
-
statusMessage: ctx.error.message,
|
|
103
|
-
message: ctx.error.message,
|
|
104
|
-
fatal: true
|
|
105
|
-
});
|
|
103
|
+
}
|
|
106
104
|
},
|
|
107
|
-
onResponse(ctx) {
|
|
108
|
-
[interceptors.onResponse, onResponse].
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
fns?.(ctx);
|
|
105
|
+
async onResponse(ctx) {
|
|
106
|
+
const allFns = [interceptors.onResponse, onResponse].flat();
|
|
107
|
+
for (const fn of allFns) {
|
|
108
|
+
if (fn) {
|
|
109
|
+
await fn(ctx);
|
|
113
110
|
}
|
|
114
|
-
}
|
|
111
|
+
}
|
|
115
112
|
},
|
|
116
|
-
onResponseError(ctx) {
|
|
117
|
-
[interceptors.onResponseError, onResponseError].
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
fns?.(ctx);
|
|
113
|
+
async onResponseError(ctx) {
|
|
114
|
+
const allFns = [interceptors.onResponseError, onResponseError].flat();
|
|
115
|
+
for (const fn of allFns) {
|
|
116
|
+
if (fn) {
|
|
117
|
+
await fn(ctx);
|
|
122
118
|
}
|
|
123
|
-
}
|
|
124
|
-
throw createError({
|
|
125
|
-
statusCode: 500,
|
|
126
|
-
statusMessage: ctx.request.toString(),
|
|
127
|
-
message: ctx.response._data,
|
|
128
|
-
fatal: true
|
|
129
|
-
});
|
|
119
|
+
}
|
|
130
120
|
}
|
|
131
121
|
};
|
|
132
122
|
const hashValue = ["custom_fetch:", url];
|
package/dist/types.d.mts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-custom-fetch",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.3.
|
|
4
|
+
"version": "2.3.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -9,12 +9,11 @@
|
|
|
9
9
|
},
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"import": "./dist/module.mjs"
|
|
13
|
-
"require": "./dist/module.cjs"
|
|
12
|
+
"import": "./dist/module.mjs"
|
|
14
13
|
}
|
|
15
14
|
},
|
|
16
|
-
"main": "./dist/module.
|
|
17
|
-
"types": "./dist/types.d.
|
|
15
|
+
"main": "./dist/module.mjs",
|
|
16
|
+
"types": "./dist/types.d.mts",
|
|
18
17
|
"files": [
|
|
19
18
|
"dist"
|
|
20
19
|
],
|
|
@@ -36,25 +35,25 @@
|
|
|
36
35
|
}
|
|
37
36
|
},
|
|
38
37
|
"dependencies": {
|
|
39
|
-
"@nuxt/kit": "^3.16.
|
|
38
|
+
"@nuxt/kit": "^3.16.2",
|
|
40
39
|
"ohash": "^2.0.11"
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
|
43
|
-
"@antfu/eslint-config": "^4.
|
|
42
|
+
"@antfu/eslint-config": "^4.12.0",
|
|
44
43
|
"@commitlint/cli": "^19.8.0",
|
|
45
44
|
"@commitlint/config-conventional": "^19.8.0",
|
|
46
|
-
"@nuxt/module-builder": "^0.
|
|
47
|
-
"@nuxt/schema": "^3.16.
|
|
48
|
-
"@types/node": "^22.
|
|
45
|
+
"@nuxt/module-builder": "^1.0.1",
|
|
46
|
+
"@nuxt/schema": "^3.16.2",
|
|
47
|
+
"@types/node": "^22.14.1",
|
|
49
48
|
"changelogen": "^0.6.1",
|
|
50
49
|
"commitizen": "^4.3.1",
|
|
51
50
|
"cz-git": "^1.11.1",
|
|
52
|
-
"eslint": "^9.
|
|
51
|
+
"eslint": "^9.24.0",
|
|
53
52
|
"husky": "^9.1.7",
|
|
54
|
-
"lint-staged": "^15.5.
|
|
53
|
+
"lint-staged": "^15.5.1",
|
|
55
54
|
"nitro": "npm:nitropack",
|
|
56
|
-
"nuxt": "^3.16.
|
|
57
|
-
"typescript": "5.8.
|
|
55
|
+
"nuxt": "^3.16.2",
|
|
56
|
+
"typescript": "5.8.3"
|
|
58
57
|
},
|
|
59
58
|
"husky": {
|
|
60
59
|
"hooks": {
|
package/dist/module.cjs
DELETED
package/dist/module.d.ts
DELETED
package/dist/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { type ModuleOptions, default } from './module'
|