import { Recipe } from "@/types/recipes"; async function api(url: string): Promise { const response = await fetch(url); if (!response.ok) { throw new Error(response.statusText); } return await response.json(); } async function mockAPI(data: T): Promise { return new Promise((resolve) => { resolve(data); }) } export const getAllRecipes = () => api(`${process.env.API_RECIPES}/all/`) type Tag = { name: string, }; export const getAllTags = () => mockAPI( [ { name: 'Dinner' }, { name: 'Snack' }, { name: 'Dessert' }, { name: 'Lunch' } ] ); export const getRecipe = (id: string) => api(`${process.env.API_RECIPES}/id/${id}/`); export default { getAllRecipes, getAllTags, getRecipe, };