I'm using SvelteKit with Typescript. In $lib folder, I have an .ts file.
I try to acces the user/session from '$app/stores' in the .ts file.
import { get } from 'svelte/store';
import { session } from "$app/stores";
function getUser(){
const {user} = get(session);
console.log(user);
}
But when the function is called, i get the follow error message in the console:
Uncaught (in promise) Error: Function called outside component initialization
How can I slove this?
Many thanks!