fix(nuxt): handle immediate errors when calling useAsyncData (#6441)

This commit is contained in:
YuTin Liu 2022-08-09 16:01:25 +08:00 committed by GitHub
parent ae388e7293
commit 03cd6717ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -131,8 +131,8 @@ export function useAsyncData<
}
asyncData.pending.value = true
// TODO: Cancel previous promise
// TODO: Handle immediate errors
nuxt._asyncDataPromises[key] = Promise.resolve(handler(nuxt))
nuxt._asyncDataPromises[key] = Promise.resolve()
.then(() => handler(nuxt))
.then((result) => {
if (options.transform) {
result = options.transform(result)