2024-06-29 17:04:08 +00:00
|
|
|
|
|
|
|
function _(key: string, value: any | null | undefined = undefined): any | null {
|
|
|
|
const x = <any>window;
|
|
|
|
if (value !== undefined) {
|
|
|
|
x[key] = value;
|
|
|
|
}
|
|
|
|
return x[key];
|
|
|
|
}
|
|
|
|
|
|
|
|
function $(id: string): HTMLElement | null {
|
|
|
|
return document.getElementById(id);
|
|
|
|
}
|
|
|
|
|
2024-07-01 03:51:25 +00:00
|
|
|
async function authorizedFetch(method: string, uri: string, body: any): Promise<Response> {
|
|
|
|
const headers = new Headers()
|
|
|
|
headers.set('Authorization', 'Bearer ' + _("skey"))
|
|
|
|
return await fetch(uri, {
|
|
|
|
method: method,
|
|
|
|
headers: headers,
|
|
|
|
body: body,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export default { _, $, authorizedFetch }
|