попытка сделать нормальный интерцептор
This commit is contained in:
@@ -1 +1 @@
|
||||
export * from './useGetProductList'
|
||||
export * from './useGetProductsDetail'
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import { useQuery } from '@tanstack/vue-query'
|
||||
import { getProductList } from '~/api/endpoints'
|
||||
|
||||
export const useGetProductList = () => {
|
||||
return useQuery({
|
||||
queryKey: ['get-product-list'],
|
||||
queryFn: () => getProductList(),
|
||||
})
|
||||
}
|
||||
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