Public
Back
Version 20
6/26/2023
async function getAQI() {
// The realtime Air Quality Index (AQI) for any location
const myAQI = await stevekrouse.easyAQI({
location: "South Orange, New Jersey 07079",
});
let direction = "";
if (myAQI.aqi < @me.databaseVal["AQI"]) {
direction = "improving";
}
else if (myAQI.aqi > me.databaseVal["AQI"]) {
direction = "getting worse";
}
else {
direction = "stable";
}
const aqiStore = me.databaseVal.push({
"AQI": Number(myAQI.aqi),
"severity": myAQI.severity,
});
const messageText =
`The AQI is ${direction} at ${myAQI.aqi} which is categorized as ${myAQI.severity}.`;
console.log(messageText);
if (myAQI.severity !== "Good" || direction === "improving") {
console.email(me.helloMe, messageText);
}
}
Updated: October 23, 2023