import type { RecipeModel } from "../../models/RecipeModel" import { get } from "../utils/requests"; /** * Util for handling the recipe api */ // read base url from .env file const BASE_URL = import.meta.env.VITE_API_BASE; /** * URL for handling recipes header data */ const RECIPE_URL = `${BASE_URL}/compact-recipe` /** * Load list of all recipes * @param searchString Search string for filtering recipeList * @returns Array of recipe */ export async function fetchRecipeList(searchString : string): Promise { let url : string = RECIPE_URL; // add an s to the base URL as we want to load a list // if there's a search string add it as query parameter if(searchString && searchString !== ""){ url +="?search=" + searchString; } const res = await get(url); return res.json(); }