Admin page

This commit is contained in:
2026-10-29 21:42:26 -03:00
parent 07e61d9dd1
commit f7f34e1a57
18 changed files with 369 additions and 13 deletions
+12 -2
View File
@@ -22,10 +22,20 @@ export async function fetch_json<T>(url: string, init: RequestInit): Promise<Pos
return { ok: true, data: data as T };
}
export function post_json<T>(url: string, body: unknown, method = "POST"): Promise<PostJsonResult<T>> {
export function post_json<T>(
url: string,
body: unknown,
method = "POST",
headers: Record<string, string> = {},
): Promise<PostJsonResult<T>> {
return fetch_json<T>(url, {
method,
headers: { "Content-Type": "application/json" },
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify(body),
});
}
// The user's code from AskCode, sent as a bearer token
export function auth_headers() {
return { Authorization: `Bearer ${localStorage.getItem("code") ?? ""}` };
}