28 lines
790 B
TypeScript
28 lines
790 B
TypeScript
![]() |
import { PatchUserRequest, User } from "@root/model/user";
|
||
|
import { authStore } from "@root/stores/makeRequest";
|
||
|
|
||
|
|
||
|
const apiUrl = process.env.NODE_ENV === "production" ? "" : "https://hub.pena.digital";
|
||
|
|
||
|
const makeRequest = authStore.getState().makeRequest;
|
||
|
|
||
|
export function getUser(userId: string): Promise<User | null> {
|
||
|
return makeRequest<never, User>({
|
||
|
url: `${apiUrl}/user/${userId}`,
|
||
|
contentType: true,
|
||
|
method: "GET",
|
||
|
useToken: false,
|
||
|
withCredentials: false,
|
||
|
});
|
||
|
}
|
||
|
|
||
|
export function patchUser(user: PatchUserRequest) {
|
||
|
return makeRequest<PatchUserRequest, User>({
|
||
|
url: apiUrl + "/user/",
|
||
|
contentType: true,
|
||
|
method: "PATCH",
|
||
|
useToken: true,
|
||
|
withCredentials: false,
|
||
|
body: user,
|
||
|
});
|
||
|
}
|