Files
juwan-frontend/lib/api/users.ts
T
2026-03-01 22:51:03 +08:00

17 lines
482 B
TypeScript

import { httpJson } from "@/lib/api/http"
import { isApiError } from "@/lib/errors"
import type { User } from "@/lib/types"
export async function getUserById(userId: string): Promise<User | undefined> {
try {
return await httpJson<User>(`/api/v1/users/${userId}`)
} catch (err) {
if (isApiError(err) && err.code === 404) return undefined
throw err
}
}
export async function getCurrentUserForLogin(): Promise<User> {
return httpJson<User>("/api/v1/users/me")
}