mirror of
https://github.com/Roslund/sthlm-mesh.git
synced 2026-03-28 17:43:02 +01:00
22 lines
550 B
JavaScript
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;
|
|
}
|