what's a better way to fetch a single user

right now if i want to fetch a single user i have to use code like this
  const { data, error } = await schoologyUsers.select().eq("email", email);
  if (!data) throw error;
  const user = data[0];

however this has some problems
  • boilerplatey
  • declares data and error so i can't use them again
    what's a better way to do this? (and yes thankfully this is inside of another reusable function, but i've had to do something like this a couple times)
Was this page helpful?