function login() { const username = document.getElementById('login-username').value; const password = document.getElementById('login-password').value; apiPost('/auth/login', { username, password }) .then(data => showResult('login-result', data)) .catch(err => console.error(err)); } function changePassword() { const username = document.getElementById('change-username').value; const oldPassword = document.getElementById('old-password').value; const newPassword = document.getElementById('new-password').value; apiPost('/auth/change_password', { username, old_password: oldPassword, new_password: newPassword }) .then(data => showResult('change-password-result', data)) .catch(err => console.error(err)); }