Skip to content

Commit b57c68c

Browse files
committed
Return cached data if API call fails
This is probably due to a HTTP 429 (Too many requests). If the MagicMirror is throttled we should fall back to the cached data.
1 parent 0930ed0 commit b57c68c

File tree

1 file changed

+6
-1
lines changed
  • modules/default/weather/providers

1 file changed

+6
-1
lines changed

modules/default/weather/providers/yr.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ WeatherProvider.register("yr", {
119119
})
120120
.catch((err) => {
121121
Log.error(err);
122-
reject("Unable to get weather data from Yr.");
122+
if (weatherData) {
123+
Log.warn("Using outdated cached weather data.");
124+
resolve(weatherData);
125+
} else {
126+
reject("Unable to get weather data from Yr.");
127+
}
123128
})
124129
.finally(() => {
125130
localStorage.removeItem("yrIsFetchingWeatherData");

0 commit comments

Comments
 (0)