Open jlemonz opened 1 month ago
Hi,
How can i use this with pinia? I tried this code. But this gives errors that it cannot fetch when i try to login.
`// stores/auth.js
import { defineStore } from 'pinia'; import { ref, computed } from 'vue'; import { useSupabaseClient } from '#imports';
export const useAuthStore = defineStore('auth', () => { const supabase = useSupabaseClient(); const user = ref(null); const error = ref(null);
const isAuthenticated = computed(() => !!user.value);
const signIn = async (email, password) => { try { const { data, error: signInError } = await supabase.auth.signInWithPassword({ email, password, }); if (signInError) throw signInError; user.value = data.user; } catch (err) { error.value = err.message; } };
return { user, error, isAuthenticated, signIn }; }); `
Hi,
How can i use this with pinia? I tried this code. But this gives errors that it cannot fetch when i try to login.
`// stores/auth.js
import { defineStore } from 'pinia'; import { ref, computed } from 'vue'; import { useSupabaseClient } from '#imports';
export const useAuthStore = defineStore('auth', () => { const supabase = useSupabaseClient(); const user = ref(null); const error = ref(null);
const isAuthenticated = computed(() => !!user.value);
const signIn = async (email, password) => { try { const { data, error: signInError } = await supabase.auth.signInWithPassword({ email, password, }); if (signInError) throw signInError; user.value = data.user; } catch (err) { error.value = err.message; } };
return { user, error, isAuthenticated, signIn }; }); `