Recipe Search Template with edamam.com api
# 🤝help
b
a the Hi, Im using recipe search premade template and using new code generated from chatbot for edamam.com api instead of spoonacular but Im reciving following error and more one thing I didn't change second code on node "process api". Check your premade template. "Error executing action "inline-ins-c9e62a09eb.js" in flow:Main:node:process-api-data [TypeError, Cannot read properties of undefined (reading 'map')]" and the code Im using in call api node is: "async function getRecipes() { const baseUrl = 'https://api.edamam.com/api/recipes/v2'; const query = 'workflow.baseQuery'; // Replace this with your actual search query const apiKey = 'ddbe29a17e2a016c0e1ee8e707bfcee4'; // Replace this with your Edamam API key const number = '3'; const ignorePantry = 'false'; const sort = 'popularity'; const sortDirection = 'asc'; const addRecipeInformation = 'true'; const addRecipeNutrition = 'false'; const url = `${baseUrl}?q=${query}&apiKey=${apiKey}&number=${number}&ignorePantry=${ignorePantry}&sort=${sort}&sortDirection=${sortDirection}&addRecipeInformation=${addRecipeInformation}&addRecipeNutrition=${addRecipeNutrition}`; try { const response = await axios.get(url); if (response.status === 200) { const recipeInfo = response.data.results; // Save the recipeInfo to the desired location, e.g., a variable or a file workflow.recipeInfo = recipeInfo; console.log('Recipes retrieved and saved successfully:', recipeInfo); } else { console.log('Failed to retrieve recipes:', response.statusText); } } catch (error) { console.log('An error occurred:', error.message); } } // Run the action with await await getRecipes(); "
Here is the second code: workflow.recipes = [] const myCards = workflow.recipeInfo.map((recipe) => { workflow.recipes.push({ title: recipe.title, vegetarian: recipe.vegetarian, vegan: recipe.vegan, glutenFree: recipe.glutenFree, dairyFree: recipe.dairyFree, veryHealthy: recipe.veryHealthy, cheap: recipe.cheap, veryPopular: recipe.veryPopular, readyInMinutes: recipe.readyInMinutes, servings: recipe.servings, summary: recipe.summary }) // create the card object return { type: 'card', title: { dynamicValue:
${recipe.title}
, valueType: 'dynamic' }, subtitle: { dynamicValue: '', valueType: 'dynamic' }, imageUrl: { dynamicValue:
${recipe.image}
, valueType: 'dynamic' }, actions: [ { action: 'url', label: 'View Recipe', value:
${recipe.sourceUrl}
} ] } }) workflow.cards = [] for (var card of myCards) { workflow.cards.push({ //in order to render a card, we only need these three fields title: card.title, imageUrl: card.imageUrl, actions: card.actions[0] }) }
11 Views