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 asyncData.pending.value = true
// TODO: Cancel previous promise // TODO: Cancel previous promise
// TODO: Handle immediate errors nuxt._asyncDataPromises[key] = Promise.resolve()
nuxt._asyncDataPromises[key] = Promise.resolve(handler(nuxt)) .then(() => handler(nuxt))
.then((result) => { .then((result) => {
if (options.transform) { if (options.transform) {
result = options.transform(result) result = options.transform(result)