Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

Commit 5232c1b

Browse files
authored
fix(nuxt): immediately call asyncData handler (#6472)
1 parent fe26b94 commit 5232c1b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/nuxt/src/app/composables/asyncData.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,14 @@ export function useAsyncData<
131131
}
132132
asyncData.pending.value = true
133133
// TODO: Cancel previous promise
134-
nuxt._asyncDataPromises[key] = Promise.resolve()
135-
.then(() => handler(nuxt))
134+
nuxt._asyncDataPromises[key] = new Promise<DataT>(
135+
(resolve, reject) => {
136+
try {
137+
resolve(handler(nuxt))
138+
} catch (err) {
139+
reject(err)
140+
}
141+
})
136142
.then((result) => {
137143
if (options.transform) {
138144
result = options.transform(result)

0 commit comments

Comments
 (0)