(lat, long)
| 106 | * @returns {object} |
| 107 | */ |
| 108 | export 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 |
no test coverage detected