{"size": 815, "ext": "js", "max_stars_repo_path": "public/js/password.js", "max_stars_repo_name": "benthackray/pye", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/js/password.js", "max_issues_repo_name": "benthackray/pye", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/js/password.js", "max_forks_repo_name": "benthackray/pye", "max_forks_repo_forks_event_min_datetime": "2021-07-19T16:20:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-20T16:26:35.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 27.1666666667, "max_line_length": 89, "alphanum_fraction": 0.5950920245}
const passwordFormHandler = async (event) => {
    event.preventDefault();

    const password = document.querySelector('#new-password').value.trim();
    const confirmPassword = document.querySelector('#confirm-new-password').value.trim();


    if (password !== confirmPassword) {
        alert('Passwords do not match')
        return
    }

    if (password) {

        const response = await fetch('/api/user/password', {
            method: 'PUT',
            body: JSON.stringify({ password }),
            headers: { 'Content-Type': 'application/json' },
        });

        if (response.ok) {
            alert('Successfully updated password!');
            document.location.reload();
        }
    }
};

document
    .querySelector('.password-form')
    .addEventListener('submit', passwordFormHandler);