This commit is contained in:
hailin 2025-04-21 13:12:35 +08:00
parent 36e69b3e55
commit bafe7959b7
1 changed files with 10 additions and 0 deletions

View File

@ -2,16 +2,26 @@ import { supabase } from "@/lib/supabase/browser-client"
import { TablesInsert, TablesUpdate } from "@/supabase/types"
export const getProfileByUserId = async (userId: string) => {
console.log(`..................Fetching profile for userId: ${userId}`) // 日志:打印查询的用户 ID
const { data: profile, error } = await supabase
.from("profiles")
.select("*")
.eq("user_id", userId)
.single()
if (error) {
console.error(`Error fetching profile: ${error.message}`) // 错误日志
throw new Error(error.message)
}
if (!profile) {
console.log(`No profile found for userId: ${userId}`) // 日志:如果没有找到 profile
throw new Error(error.message)
}
console.log(`Found profile for userId: ${userId}`, profile) // 日志:打印找到的 profile
return profile
}