SupabaseS
Supabase6mo ago
Shanks

Table not returning the required data

I am trying to get a table from the supabase from database biut it is not returning anything.
export async function getAllGames(): Promise<Game[]> {
  const supabase = await createClient();
  const { data, error } = await supabase
    .from('games')
    .select();
    // .order('created_at', { ascending: true });
  if (error) {
    console.error('getAllGames error:', error);
    return [];
  }
  console.log(data);
  return (data || []) as Game[];

}

And this is where I am calling it
useEffect(() => {
        setLoading(true);
        setError(null);
        getAllGames()
            .then((games) => setGames(games))
            .catch((err) => {
                setError('Failed to load games.');
                console.error(err);
            })
            .finally(() => setLoading(false));
    }, []);
I have already populated it but it is not returing anything
DO i have to create some RLS or some other error?
Was this page helpful?