SupabaseS
Supabase6mo ago
Tariq

Getting type issues with Supabase data

For some reason supabase keeps giving me the wrong type. It believes "followed" is a list of objects when really it should only be one singular object.

I don't know what Im doing wrong for it to get this type.

The code for the function is below:
export const getFollowing = async () => {
  const {
    data: { user },
    error: authError,
  } = await supabase.auth.getUser();

  if (authError || !user) throw new Error("Not authenticated.");

  const { data, error } = await supabase
    .from("follows")
    .select("followed_id, followed:followed_id ( id, username, avatar_url )")
    .eq("follower_id", user.id);

  if (error) throw new Error(error.message);

  return data ?? [];
};
image.png
Was this page helpful?