supabase.from().select() finished unexpectedly and doesn’t occur any errors

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(…


This content originally appeared on DEV Community and was authored by Cojiroooo

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(async (event, session) => {
  // ...
  setTimeout(() => {
    afterSignedIn();
  }, 0);
});



This content originally appeared on DEV Community and was authored by Cojiroooo


Print Share Comment Cite Upload Translate Updates
APA

Cojiroooo | Sciencx (2024-09-10T03:01:03+00:00) supabase.from().select() finished unexpectedly and doesn’t occur any errors. Retrieved from https://www.scien.cx/2024/09/10/supabase-from-select-finished-unexpectedly-and-doesnt-occur-any-errors/

MLA
" » supabase.from().select() finished unexpectedly and doesn’t occur any errors." Cojiroooo | Sciencx - Tuesday September 10, 2024, https://www.scien.cx/2024/09/10/supabase-from-select-finished-unexpectedly-and-doesnt-occur-any-errors/
HARVARD
Cojiroooo | Sciencx Tuesday September 10, 2024 » supabase.from().select() finished unexpectedly and doesn’t occur any errors., viewed ,<https://www.scien.cx/2024/09/10/supabase-from-select-finished-unexpectedly-and-doesnt-occur-any-errors/>
VANCOUVER
Cojiroooo | Sciencx - » supabase.from().select() finished unexpectedly and doesn’t occur any errors. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/10/supabase-from-select-finished-unexpectedly-and-doesnt-occur-any-errors/
CHICAGO
" » supabase.from().select() finished unexpectedly and doesn’t occur any errors." Cojiroooo | Sciencx - Accessed . https://www.scien.cx/2024/09/10/supabase-from-select-finished-unexpectedly-and-doesnt-occur-any-errors/
IEEE
" » supabase.from().select() finished unexpectedly and doesn’t occur any errors." Cojiroooo | Sciencx [Online]. Available: https://www.scien.cx/2024/09/10/supabase-from-select-finished-unexpectedly-and-doesnt-occur-any-errors/. [Accessed: ]
rf:citation
» supabase.from().select() finished unexpectedly and doesn’t occur any errors | Cojiroooo | Sciencx | https://www.scien.cx/2024/09/10/supabase-from-select-finished-unexpectedly-and-doesnt-occur-any-errors/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.