document.addEventListener('DOMContentLoaded', async () => { const adminLink = document.getElementById('admin-link'); if (adminLink === null) { return; } const response = await fetch('/api/auth/me', { credentials: 'same-origin', }); if (!response.ok) { return; } const body = await response.json(); if (body.user && body.user.isAdmin === true) { adminLink.hidden = false; } });