Loading js/index.mjs +7 −7 Original line number Diff line number Diff line const apiBase = "/api/v1/services" const apiBase = "/api/v2/services" /** * Query the api endpoint /api/v1/services, which returns a list of objects, each representing a service. * Query the api endpoint /api/v2/status, which returns a list of objects, each representing a service. * To see what a service object looks like, check the API documentation. * * @see https://status.fsco.li/api/v1 * @see https://status.fsco.li/api/v2 * @returns A list of service objects */ async function getServices() { async function getStatus() { /* * Use fetch to make an HTTPS request to the API. fetch() is an asynchronous function, * meaning we have to "wait" for it to return using `await` (the nice thing is that * the code doesn't actually have to wait when using `await`, instead it can do something * else and will only return here when fetch is completed). * * Because we use `await` in this function, the function `getServices()` needs to be marked `async`, * and we need to use `await` whenever we want to call `getServices()`. * Because we use `await` in this function, the function `getStatus()` needs to be marked `async`, * and we need to use `await` whenever we want to call `getStatus()`. */ const response = await fetch(apiBase) return response.json() Loading Loading @@ -91,7 +91,7 @@ function createStatusBadge(service) { } // The lines below are run as soon as the file is loaded. const services = await getServices() const services = await getStatus() services.forEach(service => { const p = document.createElement("p") p.appendChild(createStatusBadge(service)) Loading Loading
js/index.mjs +7 −7 Original line number Diff line number Diff line const apiBase = "/api/v1/services" const apiBase = "/api/v2/services" /** * Query the api endpoint /api/v1/services, which returns a list of objects, each representing a service. * Query the api endpoint /api/v2/status, which returns a list of objects, each representing a service. * To see what a service object looks like, check the API documentation. * * @see https://status.fsco.li/api/v1 * @see https://status.fsco.li/api/v2 * @returns A list of service objects */ async function getServices() { async function getStatus() { /* * Use fetch to make an HTTPS request to the API. fetch() is an asynchronous function, * meaning we have to "wait" for it to return using `await` (the nice thing is that * the code doesn't actually have to wait when using `await`, instead it can do something * else and will only return here when fetch is completed). * * Because we use `await` in this function, the function `getServices()` needs to be marked `async`, * and we need to use `await` whenever we want to call `getServices()`. * Because we use `await` in this function, the function `getStatus()` needs to be marked `async`, * and we need to use `await` whenever we want to call `getStatus()`. */ const response = await fetch(apiBase) return response.json() Loading Loading @@ -91,7 +91,7 @@ function createStatusBadge(service) { } // The lines below are run as soon as the file is loaded. const services = await getServices() const services = await getStatus() services.forEach(service => { const p = document.createElement("p") p.appendChild(createStatusBadge(service)) Loading