diff --git a/static/mainpage.js b/static/mainpage.js index 1f80c40..42f75dc 100644 --- a/static/mainpage.js +++ b/static/mainpage.js @@ -33,10 +33,15 @@ async function listPublicGroups() { let l; try { - l = await (await fetch('/public-groups.json')).json(); + let r = await fetch('/public-groups.json'); + if(!r.ok) + throw new Error(`${r.status} ${r.statusText}`); + l = await r.json(); } catch(e) { - console.error(e); - l = []; + table.textContent = `Couldn't fetch groups: ${e}`; + div.classList.remove('nogroups'); + div.classList.add('groups'); + return; } if (l.length === 0) { diff --git a/static/stats.js b/static/stats.js index bb67547..3746d96 100644 --- a/static/stats.js +++ b/static/stats.js @@ -25,10 +25,14 @@ async function listStats() { let l; try { - l = await (await fetch('/stats.json')).json(); + let r = await fetch('/stats.json'); + if(!r.ok) + throw new Error(`${r.status} ${r.statusText}`); + l = await r.json(); } catch(e) { console.error(e); - l = []; + table.textContent = `Couldn't fetch stats: ${e}`; + return; } if(l.length === 0) {