I am new to sveltekit and svelte in general, and I am trying to load data from an API to the stores, here is how I am doing it
export const load = async ({ fetch }) => {
const data = get(dataStore);
if (browser && data) {
return { status: 200 };
}
const res = await fetch('/data.json', { credentials: 'include', mode: 'cors' });
const data = await res.json();
if (browser) {
dataStore.set(data);
}
return { status: res.status };
};
my question is what is best approach to load data on SSR to the FE stores ?