Spaces:
No application file
No application file
| const ACCELERATOR_URL = "http://deine-server-ip:5000"; // Deine Server-Adresse | |
| const Accelerator = { | |
| // Daten zum Server senden (Speichern) | |
| async save(data) { | |
| try { | |
| const response = await fetch(`${ACCELERATOR_URL}/api/sync`, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| // WICHTIG: Erlaubt das Senden/Empfangen von Session-Cookies | |
| credentials: 'include', | |
| body: JSON.stringify(data) | |
| }); | |
| return await response.json(); | |
| } catch (err) { | |
| console.error("Accelerator Save Error:", err); | |
| } | |
| }, | |
| // Daten vom Server abrufen (Laden) | |
| async load() { | |
| try { | |
| const response = await fetch(`${ACCELERATOR_URL}/api/sync`, { | |
| method: 'GET', | |
| credentials: 'include' | |
| }); | |
| return await response.json(); | |
| } catch (err) { | |
| console.error("Accelerator Load Error:", err); | |
| } | |
| } | |
| }; | |
| // Beispiel-Anwendung: | |
| // Accelerator.save({ score: 100, theme: 'dark' }).then(console.log); | |
| // Accelerator.load().then(data => console.log("Deine Daten:", data)); |