export async function getServerSideProps({ res }) { res.setHeader("Cache-Control", "public, s-maxage=10, stale-while-revalidate=59") const gamesResponse = await fetch("http://localhost:3000/api/games", { method: "GET", headers: { "Content-Type": "application/json", }, }) const allGames = await gamesResponse.json() const teamsResponse = await fetch("http://localhost:3000/api/teams", { method: "GET", headers: { "Content-Type": "application/json", }, }) const allTeams = await teamsResponse.json() return { props: { allGames, allTeams }, } } export default function Dashboard({ allGames, allTeams }) { const findTeam = (id) => { return allTeams?.data.find((team) => team._id === id) } return ( <>

IsaCon

Games

{allGames.data.map((game) => (
{findTeam(game.homeTeam).logo?._meta.url ? ( Sunset in the mountains ) : ( findTeam(game.homeTeam).name )}
{findTeam(game.awayTeam).logo?._meta.url ? ( Sunset in the mountains ) : ( findTeam(game.awayTeam).name )}
{game.homeScore} - {game.awayScore}
))}
) }