import useSWR, { responseInterface } from 'swr'; import { get } from '../requests'; type Response = responseInterface; export interface Product { _id: string; name: string; description: string; price: number; quantity: number; specs: any; createdAt: string; updatedAt: string; } const fetcher = (endpoint: string) => get(endpoint).then(response => response.data); export const useProducts = (): Response => { return useSWR('/products', fetcher); };