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