Skip to content

Commit

Permalink
fix(nuxt): revert change to getCachedData null response
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Jul 18, 2024
1 parent e21f681 commit d10cea1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/nuxt/src/app/composables/asyncData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 253,16 @@ export function useAsyncData<
}

// TODO: make more precise when v4 lands
const hasCachedData = () => options.getCachedData!(key, nuxtApp) !== undefined
const hasCachedData = () => options.getCachedData!(key, nuxtApp) != null

// Create or use a shared asyncData entity
if (!nuxtApp._asyncData[key] || !options.immediate) {
nuxtApp.payload._errors[key] ??= asyncDataDefaults.errorValue

const _ref = options.deep ? ref : shallowRef
const cachedData = options.getCachedData!(key, nuxtApp)

nuxtApp._asyncData[key] = {
data: _ref(typeof cachedData !== 'undefined' ? cachedData : options.default!()),
data: _ref(options.getCachedData!(key, nuxtApp) ?? options.default!()),
pending: ref(!hasCachedData()),
error: toRef(nuxtApp.payload._errors, key),
status: ref('idle'),
Expand Down

0 comments on commit d10cea1

Please sign in to comment.