export default class MainView {
  mount() {
    //  This will be executed when the document loads...
    document.getElementsByClassName("logout-link")[0].onclick = () => {
      let xhttp = new XMLHttpRequest();
      xhttp.open("DELETE","/logout",true);
      xhttp.send();
    };
  }
}

export default class MainView {
  mount() {
    //  This will be executed when the document loads...
    let logout_link = document.getElementsByClassName("logout-link")
    if (logout_link.length > 0) {
      logout_link[0].onclick = () => {
        let xhttp = new XMLHttpRequest();
        xhttp.open("DELETE","/logout",false);
        xhttp.send();
        window.location.href = '/'
      };
    };
  }
}

Fix JS errors on pages without logout link also redirect after logging out
Fix JS errors on pages without logout link
also redirect after logging out
