nuxt-custom-fetch 2.3.1 → 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 CHANGED
@@ -100,6 +100,7 @@ export const getInfo = (params: Record<string, any>) =>
100
100
  ```ts
101
101
  // index.vue
102
102
  import { getInfo } from './ajax'
103
+
103
104
  const { data, error, pending } = await getInfo({
104
105
  sign: 123
105
106
  })
package/dist/module.d.mts CHANGED
@@ -4,4 +4,5 @@ interface ModuleOptions {
4
4
  }
5
5
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
6
6
 
7
- export { type ModuleOptions, _default as default };
7
+ export { _default as default };
8
+ export type { ModuleOptions };
package/dist/module.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "nuxt-custom-fetch",
3
3
  "configKey": "customFetch",
4
- "version": "2.3.1",
4
+ "version": "2.3.2",
5
5
  "builder": {
6
- "@nuxt/module-builder": "1.0.0",
6
+ "@nuxt/module-builder": "1.0.1",
7
7
  "unbuild": "unknown"
8
8
  }
9
9
  }
@@ -86,53 +86,37 @@ export class CustomFetch {
86
86
  const interceptors = this.interceptors;
87
87
  const _config = reactive({ ...restAjaxConfig });
88
88
  const defaultOptions = {
89
- onRequest(ctx) {
90
- [interceptors.onRequest, onRequest].forEach((fns) => {
91
- if (Array.isArray(fns)) {
92
- fns.forEach((fn) => fn?.(ctx));
93
- } else {
94
- 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);
95
94
  }
96
- });
95
+ }
97
96
  },
98
- onRequestError(ctx) {
99
- [interceptors.onRequestError, onRequestError].forEach((fns) => {
100
- if (Array.isArray(fns)) {
101
- fns.forEach((fn) => fn?.(ctx));
102
- } else {
103
- 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);
104
102
  }
105
- });
106
- throw createError({
107
- statusCode: 400,
108
- statusMessage: ctx.error.message,
109
- message: ctx.error.message,
110
- fatal: true
111
- });
103
+ }
112
104
  },
113
- onResponse(ctx) {
114
- [interceptors.onResponse, onResponse].forEach((fns) => {
115
- if (Array.isArray(fns)) {
116
- fns.forEach((fn) => fn?.(ctx));
117
- } else {
118
- 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);
119
110
  }
120
- });
111
+ }
121
112
  },
122
- onResponseError(ctx) {
123
- [interceptors.onResponseError, onResponseError].forEach((fns) => {
124
- if (Array.isArray(fns)) {
125
- fns.forEach((fn) => fn?.(ctx));
126
- } else {
127
- 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);
128
118
  }
129
- });
130
- throw createError({
131
- statusCode: 500,
132
- statusMessage: ctx.request.toString(),
133
- message: ctx.response._data,
134
- fatal: true
135
- });
119
+ }
136
120
  }
137
121
  };
138
122
  const hashValue = ["custom_fetch:", url];
package/dist/types.d.mts CHANGED
@@ -1 +1,3 @@
1
- export { type ModuleOptions, default } from './module.mjs'
1
+ export { default } from './module.mjs'
2
+
3
+ export { type ModuleOptions } from './module.mjs'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-custom-fetch",
3
3
  "type": "module",
4
- "version": "2.3.1",
4
+ "version": "2.3.2",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -39,18 +39,18 @@
39
39
  "ohash": "^2.0.11"
40
40
  },
41
41
  "devDependencies": {
42
- "@antfu/eslint-config": "^4.11.0",
42
+ "@antfu/eslint-config": "^4.12.0",
43
43
  "@commitlint/cli": "^19.8.0",
44
44
  "@commitlint/config-conventional": "^19.8.0",
45
- "@nuxt/module-builder": "^1.0.0",
45
+ "@nuxt/module-builder": "^1.0.1",
46
46
  "@nuxt/schema": "^3.16.2",
47
- "@types/node": "^22.14.0",
47
+ "@types/node": "^22.14.1",
48
48
  "changelogen": "^0.6.1",
49
49
  "commitizen": "^4.3.1",
50
50
  "cz-git": "^1.11.1",
51
51
  "eslint": "^9.24.0",
52
52
  "husky": "^9.1.7",
53
- "lint-staged": "^15.5.0",
53
+ "lint-staged": "^15.5.1",
54
54
  "nitro": "npm:nitropack",
55
55
  "nuxt": "^3.16.2",
56
56
  "typescript": "5.8.3"