Search code examples
javascriptreactjsnext.jssupabase

supabase in Next JS returning an empty array when data is in relevant tables


It seems I am always returning an empty array when trying to pull data from my tables. This is how I am doing it, after following the docs and several tutorials.

const [tableData, setTableData] = useState([]);

  async function getTableData() {
    let { data, error } = await supabase
      .from('SignalJourneyAudienceConstraints')
      .select('*');

    setTableData(data);
    console.log(tableData);
  }

  useEffect(() => {
    getTableData();
  }, []);

I have data in the table as so.

enter image description here

The only thing I can think of is the naming of the table??

I have also tried the following

let { data: SignalJourneyAudienceConstraints, error } = await supabase
  .from('SignalJourneyAudienceConstraints')
  .select('*')

But getting an error ReferenceError: data is not defined and in VSC I'm getting All destructured elements are unused.ts(6198) with the above.

I have always seen tutorials just use data though.


Solution

  • I had to turn off RLS on my tables.