Files
diplom-frontend/app/lib/api/client/user.ts
2025-05-20 04:16:03 +03:00

39 lines
861 B
TypeScript

import axios from "../http-client"
import type { FullUser, PartialUser, RecipientChannel, UserId, Uuid } from "../types"
export async function me() {
const response = await axios.get("/users/@me")
return response.data as FullUser
}
export async function getUser(userId: UserId) {
const response = await axios.get(`/users/${userId}`)
return response.data as PartialUser
}
export async function channels() {
const response = await axios.get("/users/@me/channels")
return response.data as RecipientChannel[]
}
interface PatchUserRequest {
displayName?: string | null
avatarId?: Uuid | null
}
export async function patchUser(request: PatchUserRequest) {
const response = await axios.patch(`/users/@me`, request)
return response.data as FullUser
}
export default {
me,
channels,
getUser,
patchUser
}