form.addEventListener('submit', async e => { e.preventDefault(); const name = document.getElementById('showName').value; const date = document.getElementById('showDate').value; const link = document.getElementById('showLink').value; try { const res = await fetch('/.netlify/functions/save-shows', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({ pass: PASSWORD, action:'add', show: { name, date, link } }) }); if (!res.ok) { const text = await res.text(); throw new Error(`Server returned ${res.status}: ${text}`); } const data = await res.json(); console.log('Success:', data); document.getElementById('showName').value=''; document.getElementById('showDate').value=''; document.getElementById('showLink').value=''; loadCurrentShows(); } catch(err){ alert('Error saving show. Check console for details.'); console.error(err); } });