19 lines
594 B
TypeScript
19 lines
594 B
TypeScript
// 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ı"
|
||
)
|
||
}
|
||
}
|