import useSWR, { responseInterface } from 'swr'; import { get } from '../requests'; import { User, Event } from '../types'; type Response = responseInterface; const fetcher = (endpoint: string) => get(endpoint).then(response => response.data); export const useUser = (id: string): Response => { return useSWR(id && `/users/${id}`, fetcher); }; export const useEvents = (): Response => { return useSWR(`/events`, fetcher); };