File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,11 @@ export function useAsyncDataWrapper<T extends Record<string, any>>(
101101 // Call useAsyncData with the generated key and function
102102 const asyncDataResult = useAsyncData (
103103 dataKeyRef . value ,
104- ( ) => originalFunction ( ...unref ( argsRef ) ) ,
104+ ( ) => {
105+ const result = originalFunction ( ...unref ( argsRef ) ) ;
106+ // Ensure we return a Promise
107+ return result instanceof Promise ? result : Promise . resolve ( result ) ;
108+ } ,
105109 {
106110 // Re-execute when arguments change
107111 watch : [ argsRef ] ,
@@ -113,10 +117,18 @@ export function useAsyncDataWrapper<T extends Record<string, any>>(
113117 return asyncDataResult ;
114118 } else {
115119 // For functions without arguments
116- const asyncDataResult = useAsyncData ( key , ( ) => originalFunction ( ) , {
117- // Spread additional options
118- ...options ,
119- } ) ;
120+ const asyncDataResult = useAsyncData (
121+ key ,
122+ ( ) => {
123+ const result = originalFunction ( ) ;
124+ // Ensure we return a Promise
125+ return result instanceof Promise ? result : Promise . resolve ( result ) ;
126+ } ,
127+ {
128+ // Spread additional options
129+ ...options ,
130+ } ,
131+ ) ;
120132
121133 return asyncDataResult ;
122134 }
You can’t perform that action at this time.
0 commit comments