stop redirecting to 25karma; add basic /players/:name page
This commit is contained in:
parent
08d5864702
commit
37c14152f6
|
@ -3,7 +3,7 @@
|
|||
let ign;
|
||||
|
||||
function redir() {
|
||||
goto(`https://25karma.xyz/player/${ign}`)
|
||||
goto(`/players/${ign}`)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
|||
|
||||
<form on:submit|preventDefault={redir} class="p-3">
|
||||
<input bind:value={ign} placeholder="Enter your IGN">
|
||||
<button type="submit">Go</button>
|
||||
<button type="submit" class="border border-black">Go</button>
|
||||
</form>
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<script context="module">
|
||||
export async function load({ page: { params }, fetch }) {
|
||||
const player = params.player
|
||||
const req = await fetch(`https://api.slothpixel.me/api/players/${player}`)
|
||||
const stats = await req.json()
|
||||
if (stats.error) {
|
||||
return {
|
||||
status: 404,
|
||||
error: "Player not Found"
|
||||
}
|
||||
}
|
||||
return {
|
||||
props: {
|
||||
stats
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
export let stats;
|
||||
</script>
|
||||
|
||||
<p>{stats.username}'s UUID is {stats.uuid}</p>
|
Loading…
Reference in New Issue