Area restrita - Questionario

This commit is contained in:
2026-06-08 23:50:59 -03:00
parent f2e2400637
commit ef968f10ae
6972 changed files with 23454 additions and 2267883 deletions
+30
View File
@@ -0,0 +1,30 @@
import { env } from "../lib/env";
import type { UserProfile } from "./types";
async function kimiRequest<T>(
path: string,
token: string,
init?: RequestInit,
): Promise<T | null> {
const resp = await fetch(`${env.kimiOpenUrl}${path}`, {
...init,
headers: {
Accept: "application/json",
Authorization: `Bearer ${token}`,
...init?.headers,
},
});
if (!resp.ok) {
const text = await resp.text();
console.warn(
`[kimi] Request to ${path} failed (${resp.status}): ${text}`,
);
return null;
}
return resp.json() as Promise<T>;
}
export const users = {
getProfile: (token: string) =>
kimiRequest<UserProfile>("/v1/users/me/profile", token),
};