Add RSVP functionality with signed token auth

This commit is contained in:
Ian Gulliver
2025-12-29 13:17:02 -08:00
parent 9636171b7f
commit f459023c8c
3 changed files with 196 additions and 6 deletions

View File

@@ -14,6 +14,25 @@ export function logout() {
location.reload();
}
export async function api(method, path, body) {
const profile = getProfile();
const opts = {
method,
headers: {
'Authorization': 'Bearer ' + (profile?.token || ''),
'Content-Type': 'application/json'
}
};
if (body !== undefined) {
opts.body = JSON.stringify(body);
}
const res = await fetch(path, opts);
if (!res.ok) {
throw new Error(await res.text());
}
return res.json();
}
function bind(data) {
document.querySelectorAll('[data-bind]').forEach(el => {
const key = el.dataset.bind;