Skip to content

Commit

Permalink
Merge pull request #268 from Edvid/weather-fail-fallback
Browse files Browse the repository at this point in the history
Suggested fallback for failing wttr.in weather API
  • Loading branch information
ethancedwards8 authored Aug 18, 2024
2 parents eec7354 + 0b0b381 commit b778a57
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scripts/weather.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ fetch_weather_information()
{
display_weather=$1
# it gets the weather condition textual name (%C), and the temperature (%t)
curl -sL wttr.in/${fixedlocation// /%20}\?format="%C+%t$display_weather"
api_response=$(curl -sL wttr.in/${fixedlocation// /%20}\?format="%C+%t$display_weather")

if [[ $api_response = "Unknown location;"* ]]; then
echo "Unknown location error"
else
echo $api_response
fi
}

#get weather display
Expand Down

0 comments on commit b778a57

Please sign in to comment.