fix(nuxt): call/transform `useAsyncData` and `runWithContext`

This commit is contained in:
Daniel Roe 2023-05-03 21:42:00 +01:00
parent 566fa85fc8
commit 1c7fc72493
2 changed files with 2 additions and 2 deletions

View File

@ -143,7 +143,7 @@ export function useAsyncData<
const promise = new Promise<ResT>(
(resolve, reject) => {
try {
resolve(handler(nuxt))
resolve(nuxt.runWithContext(() => handler(nuxt)))
} catch (err) {
reject(err)
}

View File

@ -193,7 +193,7 @@ export default defineUntypedSchema({
* @type {import('unctx').TransformerOptions}
*/
asyncTransforms: {
asyncFunctions: ['defineNuxtPlugin', 'defineNuxtRouteMiddleware'],
asyncFunctions: ['defineNuxtPlugin', 'defineNuxtRouteMiddleware', 'runWithContext', 'useAsyncData'],
objectDefinitions: {
defineNuxtComponent: ['asyncData', 'setup'],
defineNuxtPlugin: ['setup'],