tkd_neu/app/app/spiele/page.tsx

34 lines
590 B
TypeScript

import React from 'react'
import Link from "next/link";
type response = {
message: string;
games: spiel[];
}
type spiel = {
id: number;
name: string;
type: number;
};
async function spiele() {
const response = await fetch("http://localhost:2006/spiele");
const data:response = await response.json();
return (
<div>
<h1> Spiele </h1>
<ul>
{data.games.map((spiel) => (
<li key={spiel.id}>
<Link href={`/spiele/${spiel.id}`}>{spiel.name}</Link>
</li>
))}
</ul>
</div>
)
}
export default spiele