Closed MTyson closed 3 years ago
I want to do something like this:
<script context="module"> export async function preload() { const topicRes = await this.fetch(`topics/all.json`).catch((error) => { console.error("ERROR: " + error) }); const serverTopics = await topicRes.json(); return { serverTopics }; } </script>
And then:
<script> import { writable } from 'svelte/store'; export let topics = writable(serverTopics); </script>
So basically, initialize the topics var with the preload value.
But in the markup:
{JSON.stringify(serverTopics)} --- {JSON.stringify(topics)}
It shows data in serverTopics but topics is empty.
Ok, I got it:
{JSON.stringify($topics)}
I want to do something like this:
And then:
So basically, initialize the topics var with the preload value.
But in the markup:
It shows data in serverTopics but topics is empty.