ws4kp-linhanced/server/scripts/modules/utils/weather.mjs

18 lines
458 B
JavaScript
Raw Normal View History

import { safeJson } from './fetch.mjs';
import { debugFlag } from './debug.mjs';
2022-12-06 16:14:56 -06:00
const getPoint = async (lat, lon) => {
const point = await safeJson(`https://api.weather.gov/points/${lat.toFixed(4)},${lon.toFixed(4)}`);
if (!point) {
if (debugFlag('verbose-failures')) {
console.warn(`Unable to get points for ${lat},${lon}`);
}
2022-12-06 16:14:56 -06:00
return false;
}
return point;
2022-12-06 16:14:56 -06:00
};
export {
// eslint-disable-next-line import/prefer-default-export
getPoint,
};