fix: crash on unavailable source api (#4)
* fix: crash on unavailable source api the screen not updating because of errors * Change temperature format if null Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit was merged in pull request #4.
This commit is contained in:
@@ -14,9 +14,15 @@ public class WeatherService(IWeatherClient weatherApi, IOptions<ApiConfiguration
|
||||
{
|
||||
private readonly ApiConfiguration _apiConfig = options.Value;
|
||||
|
||||
public Task<WeatherData> GetWeatherAsync(string lat, string lon)
|
||||
public Task<WeatherData> GetWeatherAsync(string? lat, string? lon)
|
||||
{
|
||||
var location = $"{lat},{lon}";
|
||||
|
||||
if (string.IsNullOrEmpty(lat) || string.IsNullOrEmpty(lon))
|
||||
{
|
||||
location = _apiConfig.DefaultCity;
|
||||
}
|
||||
|
||||
return weatherApi.GetForecastAsync(_apiConfig.Keys.Weather, location);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user