in cloud-run-alwayson-cpu-weather-advisory/nodejs/main.js [62:77]
async function fetchState(state) {
const api_rsp = await axios.get(URL + state); // call weather API
const advisories = api_rsp.data.features;
return advisories.map(advisory => {
const prop = advisory.properties;
return { // extract/format relevant weather alert data
area: prop.areaDesc,
headline: ('NWSheadline' in prop.parameters) ?
prop.parameters.NWSheadline[0] : prop.headline,
effective: prop.effective,
expires: prop.expires,
instructions: (!prop.instruction) ? '(none)' :
prop.instruction.replace(/\n/g, ' '),
}
});
}