Skip to content

Commit b3fbdbd

Browse files
committed
fix: set watch options correctly
1 parent 25f747f commit b3fbdbd

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/runtime/composables.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,24 @@ interface UseSanityQueryOptions<T> extends AsyncDataOptions<T> {
5656
client?: string
5757
}
5858

59-
export const useSanityQuery = <T = unknown, E = Error> (query: string, _params?: Record<string, any>, options: UseSanityQueryOptions<T> = {}) => {
60-
const { client, ..._options } = options
59+
export const useSanityQuery = <T = unknown, E = Error> (query: string, _params?: Record<string, any>, _options: UseSanityQueryOptions<T> = {}) => {
60+
const { client, ...options } = _options
6161
const sanity = useSanity(client)
6262
const params = _params ? reactive(_params) : undefined
6363
if (params) {
6464
options.watch = options.watch || []
6565
options.watch.push(params)
6666
}
67-
return useAsyncData('sanity-' + objectHash(query + (params ? JSON.stringify(params) : '')), () => sanity.fetch(query, params), _options) as AsyncData<T, E | null | true>
67+
return useAsyncData('sanity-' + objectHash(query + (params ? JSON.stringify(params) : '')), () => sanity.fetch(query, params), options) as AsyncData<T, E | null | true>
6868
}
6969

70-
export const useLazySanityQuery = <T = unknown, E = Error> (query: string, _params?: Record<string, any>, options: UseSanityQueryOptions<T> = {}) => {
71-
const { client, ..._options } = options
70+
export const useLazySanityQuery = <T = unknown, E = Error> (query: string, _params?: Record<string, any>, _options: UseSanityQueryOptions<T> = {}) => {
71+
const { client, ...options } = _options
7272
const sanity = useSanity(client)
7373
const params = _params ? reactive(_params) : undefined
7474
if (params) {
7575
options.watch = options.watch || []
7676
options.watch.push(params)
7777
}
78-
return useLazyAsyncData('sanity-' + objectHash(query + (params ? JSON.stringify(params) : '')), () => sanity.fetch(query, params), _options) as AsyncData<T, E | null | true>
78+
return useLazyAsyncData('sanity-' + objectHash(query + (params ? JSON.stringify(params) : '')), () => sanity.fetch(query, params), options) as AsyncData<T, E | null | true>
7979
}

0 commit comments

Comments
 (0)