let socket = io.connect(); /* Front-end Event */ // Disconnect document.getElementById("logout").addEventListener("click", function() { socket.emit("logout") }); /* Socket Actions */ // Disconnect socket.on("logout", data=>{ if(data.error){ alert(data.error.message); }else{ window.location.href = "/"; } })