const form = document.querySelector('#login-form'); const status = document.querySelector('#login-status'); form.addEventListener('submit', async (event) => { event.preventDefault(); status.textContent = 'Signing in...'; status.style.color = '#334155'; const response = await fetch('/api/auth/login', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(Object.fromEntries(new FormData(form))), }); if (!response.ok) { status.textContent = 'Sign-in failed.'; status.style.color = '#b91c1c'; return; } const data = await response.json(); localStorage.setItem('linklogAccessToken', data.access_token); window.location.assign('/profile'); });