30 lines
1.0 KiB
JavaScript
30 lines
1.0 KiB
JavaScript
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();
|
|
});
|