попытка сделать нормальный интерцептор
This commit is contained in:
14
api/queries/useGetProductsDetail.ts
Normal file
14
api/queries/useGetProductsDetail.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { useQuery } from '@tanstack/vue-query'
|
||||
import { unref, watch } from 'vue'
|
||||
import { getProductsDetail } from '~/api/endpoints'
|
||||
|
||||
export const useGetProductsDetail = (productId: MaybeRef<number>) => {
|
||||
const q = useQuery({
|
||||
queryKey: ['get-products-detail', unref(productId)],
|
||||
queryFn: () => getProductsDetail(unref(productId)),
|
||||
})
|
||||
|
||||
watch(() => productId, () => q.refetch())
|
||||
|
||||
return q
|
||||
}
|
||||
Reference in New Issue
Block a user