Complete the code to listen for authentication state changes using Supabase.
supabase.auth.[1]((event, session) => { console.log('Auth event:', event); });
The onAuthStateChange method is used to listen for authentication state changes in Supabase.
Complete the code to handle the 'SIGNED_IN' event inside the auth state change listener.
supabase.auth.onAuthStateChange((event, session) => {
if (event === [1]) {
console.log('User signed in:', session.user);
}
});The event 'SIGNED_IN' indicates a user has signed in.
Fix the error in the code to correctly unsubscribe from the auth state change listener.
const { data: authListener } = supabase.auth.onAuthStateChange((event, session) => {
console.log(event);
});
authListener.[1]();The unsubscribe() method is used to stop listening to auth state changes.
Fill both blanks to log the user's email when the 'SIGNED_IN' event occurs.
supabase.auth.onAuthStateChange((event, session) => {
if (event === [1]) {
console.log('Email:', session.user.[2]);
}
});Use 'SIGNED_IN' to check the event and email to access the user's email.
Fill all three blanks to correctly set up an auth state change listener that unsubscribes after logging the event.
const { data: listener } = supabase.auth.[1]((event, session) => {
console.log('Event:', [2]);
});
listener.[3]();Use onAuthStateChange to listen, log the event, and call unsubscribe() to stop listening.