fix eager post load

This commit is contained in:
Daniel Bulant 2023-04-24 09:54:55 +02:00
parent ccdf7df313
commit fc059a688a

View file

@ -9,10 +9,10 @@
console.error($page.error); console.error($page.error);
function loadPosts() { // function loadPosts() {
let posts = fetch("/api/posts.json").then(t => t.json()).catch(t => []); // let posts = fetch("/api/posts.json").then(t => t.json()).catch(t => []);
return posts; // return posts;
} // }
</script> </script>
<h1 class="text-center"> <h1 class="text-center">
@ -33,7 +33,7 @@
<Button href="/">Go to my home page</Button> <Button href="/">Go to my home page</Button>
</div> </div>
{#await loadPosts() then posts} <!-- {#await loadPosts() then posts}
{#if posts && posts.length > 0} {#if posts && posts.length > 0}
<div class="my-4 separator text-big">OR</div> <div class="my-4 separator text-big">OR</div>
@ -51,8 +51,8 @@
</main> </main>
{/if} {/if}
{:catch error} {:catch error}
<!-- Couldn't load --> <!-- Couldn't load ->
{/await} {/await} -->
<style> <style>
.flex { .flex {