import React, { useEffect, useState } from 'react'; import api from '../api'; import { Recipe } from '../types'; const RecipeList: React.FC = () => { const [recipes, setRecipes] = useState([]); const [error, setError] = useState(''); const fetchRecipes = async () => { try { const resp = await api.get('/recipes/'); setRecipes(resp.data); } catch (err: any) { setError('Failed to load recipes'); } }; useEffect(() => { fetchRecipes(); }, []); return (

Recipes

{error &&

{error}

}
    {recipes.map(r => (
  • {r.title}

    {r.description}

    Ingredients:\n{r.ingredients}
    Steps:\n{r.steps}
  • ))}
); }; export default RecipeList;