Dateien nach "public" hochladen

This commit is contained in:
2024-10-14 19:54:12 +00:00
parent c96391cee8
commit 8ee1015ac2
5 changed files with 462 additions and 0 deletions

29
public/script.js Normal file
View File

@@ -0,0 +1,29 @@
document.getElementById('wishForm').addEventListener('submit', async (event) => {
event.preventDefault();
const category = document.getElementById('category').value;
const link = document.getElementById('link').value;
const title = document.getElementById('title').value;
const responseMessage = document.getElementById('responseMessage');
// Senden des Wunsches an den Telegram-Bot (API-Endpunkt anpassen)
const response = await fetch('/api/sendWish', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ category, link, title })
});
if (response.ok) {
responseMessage.textContent = 'Dein Wunsch wurde gesendet!';
responseMessage.style.color = 'green';
} else {
responseMessage.textContent = 'Ein Fehler ist aufgetreten. Bitte versuche es erneut.';
responseMessage.style.color = 'red';
}
// Formular zurücksetzen
event.target.reset();
});