nuxt-custom-fetch 4.0.0-alpha.1 → 4.0.0-alpha.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/dist/runtime/ajax.js +5 -3
- package/package.json +1 -1
package/dist/runtime/ajax.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { asyncDataDefaults, pendingWhenIdle } from "#build/nuxt.config.mjs";
|
|
2
|
-
import { clearNuxtData, createError, getCurrentScope, onScopeDispose, reactive, ref, shallowRef, unref, useAsyncData, useRequestFetch, useRuntimeConfig, watch } from "#imports";
|
|
2
|
+
import { clearNuxtData, createError, getCurrentScope, onScopeDispose, reactive, ref, shallowRef, unref, useAsyncData, useNuxtApp, useRequestFetch, useRuntimeConfig, watch } from "#imports";
|
|
3
3
|
import { hash, serialize } from "ohash";
|
|
4
4
|
import { generateOptionSegments, Noop, pick } from "./utils.js";
|
|
5
5
|
const _cachedController = /* @__PURE__ */ new Map();
|
|
@@ -133,8 +133,10 @@ export class CustomFetch {
|
|
|
133
133
|
});
|
|
134
134
|
};
|
|
135
135
|
const controller = typeof AbortController !== "undefined" ? new AbortController() : {};
|
|
136
|
-
|
|
136
|
+
const nuxtApp = useNuxtApp();
|
|
137
|
+
if (import.meta.client && !nuxtApp.isHydrating) {
|
|
137
138
|
const _ref = options.deep ? ref : shallowRef;
|
|
139
|
+
options.default ??= () => asyncDataDefaults.value;
|
|
138
140
|
const asyncData = {
|
|
139
141
|
data: _ref(null),
|
|
140
142
|
error: _ref(null),
|
|
@@ -167,7 +169,7 @@ export class CustomFetch {
|
|
|
167
169
|
return asyncData;
|
|
168
170
|
}).catch((error) => {
|
|
169
171
|
asyncData.error.value = createError(error);
|
|
170
|
-
asyncData.data.value = unref(options
|
|
172
|
+
asyncData.data.value = unref(options.default());
|
|
171
173
|
asyncData.status.value = "error";
|
|
172
174
|
return asyncData;
|
|
173
175
|
}).finally(() => {
|