https://supabase.com/ logo
#javascript
Title
# javascript
b

beru

02/09/2022, 2:55 AM
@User hi sorry for pinging, I have an issue with your updated code for sveltekit supabase auth. in my`onAuthStateChange` function,
session.set
throws the error
Error: Cannot set session store before subscribing
. Do you perhaps know why this could happen? before the breaking update this wasn't an issue
s

silentworks

02/09/2022, 12:11 PM
I make sure I call the session store in my template so that it gets automatically subscribed to before I use it. You can see the example here https://github.com/silentworks/waiting-list/blob/main/src/routes/__layout.svelte#L28
b

beru

02/09/2022, 1:37 PM
ahh
then just a
console.log($session)
would fix it right?
my
__layouts.svelte
is here https://github.com/rmrt1n/cybernaut-2/blob/main/src/routes/__layout.svelte, i took the session items i needed from the load function, should i just assign $session to another variable or is that bad practice
s

silentworks

02/09/2022, 1:43 PM
You shouldn't need to reassign the $session as this is a global store and the one in the load function is a parameter that is scoped to the load function
I wouldn't console log it either as you don't really want to leave that in your production code. Calling it like I did in my template is probably the better way to go.
b

beru

02/09/2022, 3:01 PM
Thanks man its working now!