load match log asynchronously

This commit is contained in:
Ilion Beyst 2022-10-10 13:51:37 +02:00
parent f7eedc6ca1
commit 3f34ffcafc

View file

@ -4,14 +4,10 @@
try { try {
const matchId = params["match_id"]; const matchId = params["match_id"];
const apiClient = new ApiClient(fetch); const apiClient = new ApiClient(fetch);
const [matchData, matchLog] = await Promise.all([ const matchData = await apiClient.get(`/api/matches/${matchId}`);
apiClient.get(`/api/matches/${matchId}`),
apiClient.getText(`/api/matches/${matchId}/log`),
]);
return { return {
props: { props: {
matchData: matchData, matchData,
matchLog: matchLog,
}, },
}; };
} catch (error) { } catch (error) {
@ -24,9 +20,16 @@
</script> </script>
<script lang="ts"> <script lang="ts">
import { onMount } from "svelte";
import Visualizer from "$lib/components/Visualizer.svelte"; import Visualizer from "$lib/components/Visualizer.svelte";
export let matchLog: string;
export let matchLog: string | undefined;
export let matchData: object; export let matchData: object;
onMount(async () => {
const apiClient = new ApiClient();
matchLog = await apiClient.getText(`/api/matches/${matchData["id"]}/log`);
});
</script> </script>
<div class="container"> <div class="container">