axios example
by sutherland
HTML
<script src="https://unpkg.com/[email protected]/dist/axios.js"></script>
JavaScript
async function doIt() {
try {
const {
data
} = await axios.get('https://status.indiefilmlab.com/api/services')
const summary = data.filter(service => service.online === false).length > 0 ? 'Oh no! :scream_cat: It looks like there might be a problem.' : 'Nice! :tada: It looks like everything is online.'
const statuses = data.map(service => {
const emoji = service.online ? ':large_green_circle:' : ':red_circle:'
const uptimePercentage = Math.round(service.online_24_hours * 10) / 10
return emoji + ' ' + service.name + ' (' + uptimePercentage + '% uptime last 24 hours)'
})
console.log(summary + '\n' + statuses.join('\n') + '\n' + 'https://status.indiefilmlab.com')
} catch (err) {
console.log(':scream_cat: Unable to check status. This is probably a bad sign.')
}
}
doIt()