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">
|
<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 {
|
return {
|
||||||
status: res.status,
|
status: error.status,
|
||||||
error: new Error("failed to load matches"),
|
error: new Error("failed to load matches"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
Loading…
Reference in a new issue