supabase / postgrest-js

Isomorphic JavaScript client for PostgREST.
https://supabase.com
MIT License
962 stars 128 forks source link

Supabase JS library delete does not give any response #535

Closed netcamo closed 4 weeks ago

netcamo commented 1 month ago

Bug report

Describe the bug

Hi! I am using supabase js library. I was using delete function but it doesn't return any response while docs shows there should be a response (successful/unsuccessful). The delete itself works but the problem is I have no way of knowing if any errors happened or it has proceeded successfully.

Reference: https://supabase.com/docs/reference/javascript/delete

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

 try {
    const supabase = createClient();

    const { data,error } = await supabase // At the Moment Supabase does not send error related to RLS  https://github.com/supabase/supabase-js/issues/902
      .from("<tableName>")
      .delete()
      .eq("id", id);
    console.log("data", data);
    console.log(error);
    if (error) {
      console.error("Error deleting :", error.message);
      throw error;
    } else {
      return;
    }
  } catch (error) {
    console.log("Error:", error);
    throw error;
  }

Both error and data are null in all cases (successful/unsuccessfull)

Expected behavior

I would expect it to give a proper response, at least same as the example in docs:

image

System information

soedirgo commented 4 weeks ago

Hey @netcamo, the status and statusText comes from the whole response object, which you can get like so:

const { data, error, status, statusText } = await supabase
// ...

They don't come from data or error. We'll update the docs to make this clearer 👍