import { useState, useEffect } from "react"; import GameCard, { GameType } from "../components/GameCard"; export default function Games () { const [games, setGames] = useState([]); useEffect(() => { const url = `${import.meta.env.VITE_API_TITLE}/api/v1/games`; fetch(url).then((response) => { if (response.ok) { return response.json(); } throw new Error("Network response was not ok."); }).then((response) => setGames(response)); //.catch(() => navigate("/")); }, []); const allGames = games.map((game) => ( )); return ( <>
{ allGames }
); }