MCPcopy Create free account
hub / github.com/BrasilAPI/BrasilAPI / getPredictionWeatherByLocation

Function getPredictionWeatherByLocation

services/cptec/weather.js:108–127  ·  view source on GitHub ↗
(lat, long)

Source from the content-addressed store, hash-verified

106 * @returns {object}
107 */
108export const getPredictionWeatherByLocation = async (lat, long) => {
109 const url = `${CPTEC_URL}/cidade/7dias/${lat}/${long}/previsaoLatLon.xml`;
110
111 const weatherPredictions = await axios.get(url, {
112 responseType: 'application/xml',
113 responseEncoding: 'binary',
114 });
115
116 const parsed = parser.parse(weatherPredictions.data);
117
118 if (!parsed.cidade) {
119 return null;
120 }
121
122 const jsonData = formatPrediction(parsed);
123 if (jsonData.cidade === 'null') {
124 return null;
125 }
126 return jsonData;
127};
128
129/**
130 * Get weather predicion for the next {days} with a limit of 14 days

Callers 1

actionFunction · 0.90

Calls 1

formatPredictionFunction · 0.85

Tested by

no test coverage detected