Just starting with supabase, following the sveltek...
# help
n
Just starting with supabase, following the sveltekit quickstart. It's all up and running, but signout is causing me some trouble. It keeps throwing the error
null is not an object (evaluating 'ne.auth.user().id')
, even when implemented exactly as described in the quickstart. Any idea what I've done wrong? Or how to fix it?
n
Hello @ngs! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
g
You are probably going to need to provide more info on where you’re getting error. Never seen that error, in particular ne.auth make little sense.
n
ngs (2022-05-14)
n
Fair. Thanks! This all directly from the supabase sveltekit guide (https://supabase.com/docs/reference/javascript/auth-onauthstatechange). User is authenticated with a magic link. Then I call signOut() in a Profile component, like this:
Copy code
async function signOut() {
    try {
      loading = true
      let { error } = await supabase.auth.signOut()
      if (error) throw error
    } catch (error) {
      alert(error.message)
    } finally {
      loading = false
    }
    
  }
The component is nested in another a component which calls onAuthStateChange() like this:
Copy code
supabase.auth.onAuthStateChange((_, session) => {
        user.set(session.user);
    });
When attempting to sign out, supabase throws the following alerts:
null is not an object (evaluating 'i.user')
, then
null is not an object (evaluating 'ne.auth.user().id')
I've stripped the signOut function down to just a raw
const { error } = await supabase.auth.signOut()
, which itself throws the same error. The whole thing is deployed on cloudflare pages, in case that might effect anything.