How to get data back from an update?

I have a function that updates the username for a user. But, the data returned is always null. Is this by design and I need to refetch the updated user profile or am I doing something wrong?

export const handleUpdateUsername = async (id: string, username: string) => {
  const { data, error } = await supabase
    .from('profiles')
    .update({ username: username })
    .match({ id: id })
    .single();

  if (error) {
    console.log('error', error);
    return error;
  } else {
    console.log('data', data);
    return data;
  }
};
Was this page helpful?