Skip to content

Commit

Permalink
Update code (human)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrLetsplay2003 committed Oct 13, 2024
1 parent ac91471 commit 6e70d00
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function updateStatus(serverData) {
const serverSection = document.createElement('div');
serverSection.classList.add('server-section');

if (!serverData.services) {
if (serverData.services == null) {
serverSection.innerHTML = `<h2>${serverData.server} unavailable</h2>`;
statusEl.appendChild(serverSection);
return;
Expand Down Expand Up @@ -49,8 +49,17 @@ function updateStatus(serverData) {
statusEl.appendChild(serverSection);
}

async function fetchStatus(server) {
try {
let response = await fetch(server.url);
let json = await response.json();

updateStatus({ ...json, server: server.name });
} catch (e) {
updateStatus({ server: server.name });
}
}

for (let server of servers) {
fetch(server.url)
.catch(a => updateStatus({ server: server.name }))
.then(data => updateStatus({ ...data, server: server.name }))
fetchStatus(server);
}

0 comments on commit 6e70d00

Please sign in to comment.