Spaces:
Running
Running
File size: 870 Bytes
e72c2c6 3d4aa49 e72c2c6 3d4aa49 e72c2c6 3d4aa49 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | async function request(path, options = {}) {
const response = await fetch(path, {
headers: {
'Content-Type': 'application/json',
...(options.headers || {}),
},
...options,
});
if (!response.ok) {
throw new Error(`API ${response.status}: ${response.statusText}`);
}
if (response.status === 204) return null;
return response.json();
}
export async function loadRuns() {
return request('/api/runs');
}
export async function createRun(run) {
return request('/api/runs', {
method: 'POST',
body: JSON.stringify(run),
});
}
export async function updateRun(id, changes) {
return request(`/api/runs/${encodeURIComponent(id)}`, {
method: 'PUT',
body: JSON.stringify(changes),
});
}
export async function deleteRun(id) {
return request(`/api/runs/${encodeURIComponent(id)}`, {
method: 'DELETE',
});
}
|