попытка сделать нормальный интерцептор

This commit is contained in:
Veselov
2025-07-27 22:42:38 +03:00
parent 34da06301b
commit 51137c6694
10 changed files with 3369 additions and 8024 deletions

View File

@@ -1 +1 @@
export * from './useGetProductList'
export * from './useGetProductsDetail'

View File

@@ -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(),
})
}

View 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
}