Add some sort of rendering
This commit is contained in:
19
frontend/src/pages/player.astro
Normal file
19
frontend/src/pages/player.astro
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
import type { APIResponse, Player } from "../types";
|
||||||
|
|
||||||
|
const res = await fetch("http://localhost:3000/player");
|
||||||
|
const data: APIResponse<Player[]> = await res.json();
|
||||||
|
console.log(data);
|
||||||
|
---
|
||||||
|
|
||||||
|
<div>
|
||||||
|
{
|
||||||
|
data.success &&
|
||||||
|
data.data.map((player) => (
|
||||||
|
<div>
|
||||||
|
<a href={`/player/${player.name}`}>{player.name}</a>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
{!data.success && <div>{data.message}</div>}
|
||||||
|
</div>
|
7
frontend/src/pages/player/[name].astro
Normal file
7
frontend/src/pages/player/[name].astro
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
const { name } = Astro.params;
|
||||||
|
---
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h1>Hello {name}!</h1>
|
||||||
|
</div>
|
Reference in New Issue
Block a user