Here's an exciting challenge: You'll be building a small weather app, using your newfound skills with APIs!
For this lab you'll be using the Open Weather Data API. In order to use it, please follow these steps:
-
Sign up for a free Open Weather Map account!
-
Once you've signed up, you're given an API key. Copy that API key and keep track of it somewhere!
-
Go to OpenWeatherMap and scroll down, you'll see a section that says "API Documentation."
-
Open Insomnia to check out the data you're working with and to verify that your api key works. Make a GET request to the following URL in Insomnia, adding your API key to the end.
-
Review these instructions on how you should structure your API requests: https://openweathermap.org/appid#use
https://api.openweathermap.org/data/2.5/weather?q=brooklyn&appid=[PUT YOUR API KEY HERE]
https://api.openweathermap.org/data/2.5/weather?zip=10010&appid=[PUT YOUR API KEY HERE]
If you find the assignment too challenging to complete, you can bet the first place to check is your pseudocode!
-
main.js
-
index.html
-
style.css
Note: The design of the app is totally up to you, we're mainly interested in the functionality
- An input field for a user to enter a zip code or city name
- A submit button
- When the submit button is clicked:
- A GET request should fetch the weather data from the OpenWeather API
- The following data should be rendered to the page:
- City name
- Current temperature (displayed in Fahrenheit)
- Weather description
- Min temp
- Max temp
- Have the temperature turn blue if under 40, and red if above 90.
Here are some zip codes / city names to test!
- 99501 (Anchorage)
- 60605 (Chicago)
- 70124 (New Orleans)
- 77030 (Houston)
- 00902 (San Juan)
- 94123 (San Francisco)
-
Work smarter not harder, reference past work to get you started (see the Giphy API code along from lesson 08)
-
Read the Open Weather API documentation, the documentation contains code examples that helps you figure out how to use the API