Files
sthlm-mesh/static/js/status/shared.js
2025-04-14 22:55:54 +02:00

22 lines
550 B
JavaScript

let nodes = [];
let fetchPromise = null;
async function fetchNodes() {
if (nodes.length > 0) return;
if (!fetchPromise) {
fetchPromise = fetch('https://map.sthlm-mesh.se/api/v1/nodes/')
.then(res => res.json())
.then(data => {
nodes = data.nodes;
fetchPromise = null; // reset after successful fetch
})
.catch(err => {
fetchPromise = null; // reset on failure
throw err;
});
}
await fetchPromise;
}