HotTRDealsFrontend/src/api/user/getUser.ts

19 lines
594 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// src/api/user/getUser.ts
import instance from "../axiosInstance"
import type { UserProfile } from "../../models/user/UserProfile"
import { endpoints } from "@shared/contracts"
const { users } = endpoints
export async function getUser(userName: string): Promise<UserProfile> {
try {
const { data } = await instance.get(`/user/${userName}`)
return users.userProfileResponseSchema.parse(data)
} catch (err: any) {
console.error("Kullanıcı bilgileri alınamadı:", err)
throw new Error(
err.response?.data?.message || "Kullanıcı bilgileri alınamadı"
)
}
}