Files
task-inventory/public/lib/api.mjs
mikael-lovqvists-claude-agent 1100720b03 Initial project setup for task-inventory
Node.js + Express 5 backend with flat NDJSON key-value store (borrowed from
electronics-inventory). Sequential integer IDs per namespace. Vanilla JS SPA
with filters for status, priority, and tags.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 18:05:30 +00:00

17 lines
666 B
JavaScript

async function req(method, path, body) {
const opts = { method, headers: {} };
if (body !== undefined) {
opts.headers['Content-Type'] = 'application/json';
opts.body = JSON.stringify(body);
}
const res = await fetch(path, opts);
const data = await res.json();
if (!data.ok) { throw new Error(data.error ?? 'Request failed'); }
return data;
}
export const get_tasks = () => req('GET', '/api/tasks');
export const create_task = (body) => req('POST', '/api/tasks', body);
export const update_task = (id, body) => req('PUT', `/api/tasks/${id}`, body);
export const delete_task = (id) => req('DELETE', `/api/tasks/${id}`);