Fix bug with fetching data
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Dominic Grimm 2022-08-03 13:59:07 +02:00
parent 57a2d0f86e
commit f0acdc88ec

View file

@ -1,18 +1,19 @@
<script lang="ts"> <script lang="ts">
import * as api from "$lib/api"; import * as api from "$lib/api";
// let fetchData = api.fetchData(); let fetchData = api.fetchData();
let fetchData = [api.fetchData()]; // let fetchData = [api.fetchData()];
let listingIndex = 0; let listingIndex = 0;
function updateListingIndex(amount: number): void { function updateListingIndex(amount: number): void {
if (listingIndex == amount - 2) { if (listingIndex == amount - 2) {
fetchData.shift(); // fetchData.shift();
fetchData.push(api.fetchData()); // fetchData.push(api.fetchData());
} fetchData = api.fetchData();
if (fetchData.length == 0) {
fetchData.push(api.fetchData());
} }
// if (fetchData.length == 0) {
// fetchData.push(api.fetchData());
// }
if (listingIndex >= amount - 1) { if (listingIndex >= amount - 1) {
listingIndex = 0; listingIndex = 0;
@ -36,7 +37,7 @@
</script> </script>
<div class="brett center-box"> <div class="brett center-box">
{#await fetchData[0]} {#await fetchData}
<p>Loading...</p> <p>Loading...</p>
{:then data} {:then data}
{#if data.listings[listingIndex].type == api.ListingType.IMAGE} {#if data.listings[listingIndex].type == api.ListingType.IMAGE}