Spaces:
Sleeping
Sleeping
Download src/utils/storage.js from lewtun/climbing-dashboard: direct link, hf CLI and curl.
- Browser
- Download file 910 Bytes
-
https://huggingface.co/spaces/lewtun/climbing-dashboard/resolve/main/src/utils/storage.js
- Command line
-
hf download hf://spaces/lewtun/climbing-dashboard/src/utils/storage.js
-
curl -L -o storage.js https://huggingface.co/spaces/lewtun/climbing-dashboard/resolve/main/src/utils/storage.js
910 Bytes
| 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 loadSessions() { | |
| return request('/api/sessions'); | |
| } | |
| export async function createSession(session) { | |
| return request('/api/sessions', { | |
| method: 'POST', | |
| body: JSON.stringify(session), | |
| }); | |
| } | |
| export async function updateSession(id, changes) { | |
| return request(`/api/sessions/${encodeURIComponent(id)}`, { | |
| method: 'PUT', | |
| body: JSON.stringify(changes), | |
| }); | |
| } | |
| export async function deleteSession(id) { | |
| return request(`/api/sessions/${encodeURIComponent(id)}`, { | |
| method: 'DELETE', | |
| }); | |
| } | |