My Insert Statement for Supabase will not work

Viewed 16

I recently set up a supabase database and set up the client in my react app (I am using typescript with my react app). I am certain that I set up the keys for client and imported into my component correctly, because I successfully retrieved data from the database. However, when I attempt to add an api call to insert data, it doesn't work. Here is the function all from within my component, which I have linked up to a button and calling on click:

const createAccount = async () => {
  console.log('in create');
  const { data, error } = await supabase
  .from('accounts')
  .insert([
    { name: 'Test', type: 'test'},
  ])
  console.log(error);
  console.log(data);
}

I am also certain that the function is being called when I click the button (see by console.log('in create')). However, no data is being inserted to my database. When I console.log the error, I see simply 'FetchError: Failed to fetch' with no more details.

I have RLS disabled on my table, and my table is set to public. What is my data not being inserted?

0 Answers
Related