TS – Handle `{data, error} | {data, error}[]` and throw if `error` exists
I’m using supabase. In supabase, API response is structured like {data, error}
. data
is non-null if the request is succeeded and error
is non-null if the request is failed.
So If I want to call an api, I have to handle the response like this: