fix: handle invalid weather API key gracefully and fix TideDisplay crash
- Fix TideDisplay component crash (use extremes instead of tides) - Handle 401 weather API errors gracefully (return null data with note) - Update weather controller to return 200 with null values instead of 503 - Add helpful message about API key activation time - Fix tide type capitalization (High/Low instead of high/low)
This commit is contained in:
@@ -150,8 +150,13 @@ export const getWeatherData = async (
|
||||
cache.set(cacheKey, weatherData, CACHE_EXPIRATION);
|
||||
|
||||
return weatherData;
|
||||
} catch (error) {
|
||||
console.error('Error fetching weather data:', error);
|
||||
} catch (error: any) {
|
||||
// Handle specific error cases
|
||||
if (error.response?.status === 401) {
|
||||
console.warn('OpenWeatherMap API key is invalid or not activated yet. Keys can take a few hours to activate.');
|
||||
} else {
|
||||
console.error('Error fetching weather data:', error.message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user