SupabaseS
Supabase12mo ago
J

query returns empty array

(not fluent in english)

im trying to rebuild my svelte project using nextjs and i was using supabase for my backend before so i thought, why not do the same? i used npx create-next-app -e with-supabase and started tested things out. for context, i used RLS to all my tables.

i experimented with the auth first so i signed up and signed in.

// ...
import { createClient } from "@/utils/supabase/server";

export default async function AuthSection() {
  const supabaseServer = await createClient();

  const {
    data: { user }, // works fine
  } = await supabaseServer.auth.getUser();

  // ...

  return user ? (
    <UserDropdownMenu />
  ) : (
    <div className="flex gap-2">
      ...
    </div>
  );
}


but when i tried this:

import { createClient } from "@/utils/supabase/client";
import React from "react";

export default async function SampleData() {
  const supabase = createClient();

    let { data: StudentMoodData, error } = await supabase
  .from('StudentMoodEntries')
  .select('*')
          
  return <div>{JSON.stringify(StudentMoodData)}</div>;
}


it just returns an empty array. i figured it has something to do with policies so i went and check my policy on this table:

alter policy "SELECT"
on "public"."StudentMoodEntries"
to authenticated
using (
  true
);


i also logged my user:
{
    "id": "xxx",
    "aud": "authenticated",
    "role": "authenticated",
    "email": "rxxx@gmail.com",
    // ...
}


what am i missing?
image.png
Was this page helpful?