Admin page
This commit is contained in:
+12
-2
@@ -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") ?? ""}` };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user