Jey the Count
Jey the Count

Reputation: 23

Supabase delete not working through javascript client api and postman

I'm trying to delete a row in a supabase table via the javascript client api (also tried postman later). Supabase is running on a remote server via docker. I'm working with Next.js, but all cache has been disabled for a time being for testing purposes, so the issue cannot lie there.

Curiously, adding and modifying rows works. Only delete fails.

  const { data, error } = await supabase.from("menus").delete().eq("id", "1");

  if (error) {
    console.error("Error deleting row:", error);
  } else {
    console.log("Row deleted:", data);
  }
  console.error(error);

According to the documentation, the above should work (the row with id=1 exists). Instead, it returns: failed fetch

RLS is disabled. I tried using both the anon key and service_role key, with no success. Both roles have the superuser perms granted. Also given them perms to delete data. as stated above, the role has the correct perms.

I obviously checked the net and all the most common fixes, nothing worked.

EDIT

Table definition: enter image description here

Upvotes: 0

Views: 1018

Answers (1)

georg
georg

Reputation: 1

I had same issue and turns out if you have RLS policy enabled, with delete policy, you also need to create policy on select. I guess the logic is that if one can't read data, they neither can delete it.

Upvotes: 0

Related Questions