client/src/components/HeaderHome.js
// function to search for random recipes
function to search for random recipes
function to search for random recipes
async function searchRandom() {
        let recipeData;
        try {
            await searchRandomRecipe()
                .then(response => response.json())
                .then(data => recipeData = data);
            const recipes = recipeData.recipes.map((recipe) => ({
                recipeId: recipe.id,
                title: recipe.title,
                image: recipe.image || placeholder,
            }));
            setSearchedRecipes(recipes);
            console.log(recipes);
        } catch (e) {
            console.error(e);
        }
    }
async function searchRandom ( ) { let recipeData ; try { await searchRandomRecipe ( ) . then ( response => response . json ( ) ) . then ( data => recipeData = data ) ; const recipes = recipeData . recipes . map ( ( recipe ) => ( { recipeId : recipe . id , title : recipe . title , image : recipe . image || placeholder , } ) ) ; setSearchedRecipes ( recipes ) ; console . log ( recipes ) ; } catch ( e ) { console . error ( e ) ; } }
function to search for random recipes
function to search for random recipes