stop redirecting to 25karma; add basic /players/:name page

This commit is contained in:
Suhas 2021-08-02 17:47:11 -05:00
parent 08d5864702
commit 37c14152f6
2 changed files with 26 additions and 2 deletions

View File

@ -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>

View File

@ -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>