16 lines
381 B
TypeScript
16 lines
381 B
TypeScript
|
|
import { useQuery } from '@tanstack/react-query'
|
||
|
|
import { Products } from '../../types/services/products'
|
||
|
|
import { api } from '../api'
|
||
|
|
|
||
|
|
export const useProductsQuery = {
|
||
|
|
getProducts: () => {
|
||
|
|
return useQuery<Products>({
|
||
|
|
queryKey: ['products'],
|
||
|
|
queryFn: async () => {
|
||
|
|
const res = await api.get('/products')
|
||
|
|
return res.data.data
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|