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