Weather proxy: fall back to the classic request if 15-minute data is rejected
Publish Container / publish (push) Successful in 3m19s
Publish Container / publish (push) Successful in 3m19s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fd61e35b56
commit
2fb467d2e5
1 file changed
+8
-1
+8
-1
@@ -714,7 +714,14 @@ app.get('/api/weather', async (req, res) => {
|
||||
precipitation_unit: useMetric ? 'mm' : 'inch'
|
||||
});
|
||||
|
||||
const r = await fetchWithRetry(`https://api.open-meteo.com/v1/forecast?${params}`, { attempts: 3, timeoutMs: 12000, retryDelayMs: 500 });
|
||||
let r;
|
||||
try {
|
||||
// Single quick attempt with 15-minute rain data; if Open-Meteo rejects it, fall back to the classic request
|
||||
r = await fetchWithRetry(`https://api.open-meteo.com/v1/forecast?${params}`, { attempts: 1, timeoutMs: 12000 });
|
||||
} catch (firstErr) {
|
||||
params.delete('minutely_15'); params.delete('forecast_minutely_15');
|
||||
r = await fetchWithRetry(`https://api.open-meteo.com/v1/forecast?${params}`, { attempts: 3, timeoutMs: 12000, retryDelayMs: 500 });
|
||||
}
|
||||
const data = await r.json();
|
||||
setCache(cacheKey, data);
|
||||
return res.json(data);
|
||||
|
||||
Reference in new issue
Block a user