move match index to ApiClient
This commit is contained in:
parent
6f0c1093ac
commit
db7980504f
1 changed files with 12 additions and 13 deletions
|
@ -1,23 +1,22 @@
|
||||||
<script lang="ts" context="module">
|
<script lang="ts" context="module">
|
||||||
export async function load() {
|
import { ApiClient } from "$lib/api_client";
|
||||||
const res = await fetch("/api/matches", {
|
|
||||||
headers: {
|
export async function load({ fetch }) {
|
||||||
"Content-Type": "application/json",
|
try {
|
||||||
},
|
const apiClient = new ApiClient(fetch);
|
||||||
});
|
const matches = await apiClient.get("/api/matches");
|
||||||
|
|
||||||
if (res.ok) {
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
matches: await res.json(),
|
matches,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
status: error.status,
|
||||||
|
error: new Error("failed to load matches"),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
|
||||||
status: res.status,
|
|
||||||
error: new Error("failed to load matches"),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue