Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Cant figure out how to render data pulled from PocketBase in Svelte app

$
0
0

I am trying to pull a List from my PocketBase db and render in a page using svelte.On my page nothing is coming up inside the <ul>

This is my +page.svelte file.

<script lang="ts">  export let data;</script><h1>Competitions</h1><ul>  {#await data.competitions}<li>Loading Competitions...</li>  {:then competitions}    {#each competitions as competition }<li>{ competition.name }</li>    {/each}  {:catch error}<li>Error loading competitions {error.message}</li>  {/await}</ul>

and here is my +page.server.ts file.

import { pb } from '$lib/pocketbase';export async function load() {  const competitions = pb.collection('competitions').getFullList(1, {    sort: 'name'  })  return {    streamed: {      competitions: competitions.then((data) => structuredClone(data))    }  }}

I'm new to using both svelte and PocketBase so I'm not too sure what is the best way to render this information. I'm not even sure if this is the best way to load the data from the db.


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>