mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-21 07:59:33 +00:00
fix(nuxt): immediately call asyncData
handler (#6472)
This commit is contained in:
parent
fe26b943cc
commit
5232c1b5b4
@ -131,8 +131,14 @@ export function useAsyncData<
|
|||||||
}
|
}
|
||||||
asyncData.pending.value = true
|
asyncData.pending.value = true
|
||||||
// TODO: Cancel previous promise
|
// TODO: Cancel previous promise
|
||||||
nuxt._asyncDataPromises[key] = Promise.resolve()
|
nuxt._asyncDataPromises[key] = new Promise<DataT>(
|
||||||
.then(() => handler(nuxt))
|
(resolve, reject) => {
|
||||||
|
try {
|
||||||
|
resolve(handler(nuxt))
|
||||||
|
} catch (err) {
|
||||||
|
reject(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
if (options.transform) {
|
if (options.transform) {
|
||||||
result = options.transform(result)
|
result = options.transform(result)
|
||||||
|
Loading…
Reference in New Issue
Block a user