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>>(
101
101
// Call useAsyncData with the generated key and function
102
102
const asyncDataResult = useAsyncData (
103
103
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
+ } ,
105
109
{
106
110
// Re-execute when arguments change
107
111
watch : [ argsRef ] ,
@@ -113,10 +117,18 @@ export function useAsyncDataWrapper<T extends Record<string, any>>(
113
117
return asyncDataResult ;
114
118
} else {
115
119
// 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
+ ) ;
120
132
121
133
return asyncDataResult ;
122
134
}
You can’t perform that action at this time.
0 commit comments