An open API service indexing awesome lists of open source software.

https://github.com/gregolive/weather-app

Search for the weather in your city.
https://github.com/gregolive/weather-app

css html javascript openweathermap-api

Last synced: about 2 months ago
JSON representation

Search for the weather in your city.

Awesome Lists containing this project

README

          

# Weathr

Search for realtime weather info in your city.

[Live demo](https://gregolive.github.io/weather-app/) 👈

## Functionality

- Enter a city name in the search form and submit to find realtime weather at that location
- A toggle in the navbar allows the user to display temperatures in either Celcius or Fahrenheit
- Fetch weather information via the Openweathermap API
- Javascript's async and await Promise keyword's were alongside the fetch function to asynchronously obtain the weather data
- Display gif of cat banging keyboard while weather data loads
- Display location's name, current local time, temperature, feels like temperature, weather (clear, scattered clouds, heavy rain, etc.), weather icon, wind (speed and direction), pressure, humidity, visibility, and local sunrise and sunset times
- Weather icons come via fontawesome's icon pack and the colors change depending on weather and times of day (day or night)

## Reflection

The Openweathermap API has good documentation and that made querying weather data straight forward. The main issue with the current implementation is that the API key is hard coded into the query function and visible. For a project being pushed to production this would not be acceptable and Git Guardian was quick to alert me when I pushed to Github.

The weather data is queried with an async function and the await keyword ensures that the function 'pauses' until a response is returned by the fetch. The response is then processed with Javascript's .json() function.

````
const queryWeatherData = async (query) => {
const response = await fetch(URL, { mode: 'cors' });
return response.json();
};
````

To me this async/await implementation is more intuitive than the typical Promise structure and allowed me to wrap my head around error tracing more easily.

## Screenshot

weathr app screenshot