Problem
I write the below, but it doesn't occur any errors and the process terminated prematurely.
At the first time after the server started, that was successful, but that happen after the reload browser.
supabase.auth.onAuthStateChange(async (event, session) => {
// ...
const { data, error } = await supabase.from("table_name").select(); // the process finished
// ...
});
Causes
I found the answer to this problem in the document.
Do not use other Supabase functions in the callback function. If you must, dispatch the functions once the callback has finished executing. Use this as a quick way to achieve this:
https://supabase.com/docs/reference/javascript/auth-onauthstatechange
Solution
I wanted to fetch the user information when users authentication was successful.
const afterSignedIn = async () => {
const { data, error } = await supabase.from("users").select();
};
supabase.auth.onAuthStateChange((event, session) => {
// ...
setTimeout(() => {
afterSignedIn();
}, 0);
});
Top comments (2)
This doesn't work
Sorry for my late reply.
Can you tell me more details or logs??