© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•8mo ago•
17 replies
Tariq

Receiving empty array from query

This TypeScript query is giving me an empty array for profile. Is the query not correct?
export async function getProfile() {
  const supabase = await createClient();

  const {
    data: { user },
    error: userError,
  } = await supabase.auth.getUser();

  if (userError || !user) {
    devLog.error("Error getting session:", userError?.message);
    return null;
  } else {
    devLog.log("User:", user);
  }

  devLog.log("User ID:", user.id);
  const { data: profile, error: profileError } = await supabase
    .from("profiles")
    .select("*")
    .eq("id", user.id);

  if (profileError) {
    devLog.error("Error getting profile:", profileError.message);
    return null;
  } else {
    devLog.log("Profile:", profile);
  }

  return profile;
}
export async function getProfile() {
  const supabase = await createClient();

  const {
    data: { user },
    error: userError,
  } = await supabase.auth.getUser();

  if (userError || !user) {
    devLog.error("Error getting session:", userError?.message);
    return null;
  } else {
    devLog.log("User:", user);
  }

  devLog.log("User ID:", user.id);
  const { data: profile, error: profileError } = await supabase
    .from("profiles")
    .select("*")
    .eq("id", user.id);

  if (profileError) {
    devLog.error("Error getting profile:", profileError.message);
    return null;
  } else {
    devLog.log("Profile:", profile);
  }

  return profile;
}
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

query returns empty array
SupabaseSSupabase / help-and-questions
13mo ago
Empty query back.
SupabaseSSupabase / help-and-questions
4y ago
Empty array as response
SupabaseSSupabase / help-and-questions
4y ago
Select returning empty array on project but query works on supabase site
SupabaseSSupabase / help-and-questions
5mo ago