export function addNavbar() { // innerHTML only works for link and img and text, not Script tag document.querySelector('head').innerHTML += ` `; document.querySelector('.navbar-container').innerHTML = `
`; document.querySelector('.logout').addEventListener('click', async () => { const res = await fetch('/login/logout', { method: 'POST' }); if (res.status !== 200) { const data = await res.json(); alert(data.msg); return; } const result = await res.json(); if (result.status) { window.location.href = '/'; } else { alert('Unable to log out!'); } }); }