{"size": 585, "ext": "js", "max_stars_repo_path": "public/javascript/logout.js", "max_stars_repo_name": "FanCinco/Project-2", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/javascript/logout.js", "max_issues_repo_name": "FanCinco/Project-2", "max_issues_repo_issues_event_min_datetime": "2021-07-23T01:35:47.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-07T04:45:20.000Z", "max_forks_repo_path": "public/javascript/logout.js", "max_forks_repo_name": "FanCinco/Project-2", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 41, "max_forks_count": null, "avg_line_length": 23.4, "max_line_length": 72, "alphanum_fraction": 0.6256410256}
let logoutBtn = document.querySelector('#logout-btn');

window.onscroll = () =>{
    logoutBtn.classList.remove('fa-times');
}

async function logout() {
    const response = await fetch('/api/users/logout', {
        method: 'post',
        headers: { 'Content-Type': 'application/json' }
    });

    if (response.ok) {
        document.location.replace('/');
    } else {
        alert(response.statusText);
    }
}


logoutBtn.addEventListener('click', () =>{
    logoutBtn.classList.toggle('fa-times');
});

document.querySelector('#logout-btn').addEventListener('click', logout);