GithubHelp home page GithubHelp logo

hw-w07d03-fetch-weather-2's Introduction

Ajax Weather!

Here's an exciting challenge: You'll be building a small weather app, using your newfound skills with APIs!

Setting up

Make sure you follow all of these steps!

For this homework you'll be using your newfound knowledge of Ajax to create a weather app with the Open Weather API!!! This API requires you to sign up to get an API key (this way they can limit how many calls you make to their database). Here are the steps to get a key:

  1. Sign up for a free Open Weather Map account!
  2. Once you've signed up, you're given an API key. Copy that API key and keep track of it somewhere!
  3. Open Postman to check out the data you're working with & to verify that your key works. Make a GET requrest to the following URL in postman, adding your API key to the end.
http://api.openweathermap.org/data/2.5/weather?q=[ZIP CODE GOES HERE],us?units=imperial&appid=[PUT YOUR API KEY HERE]

You'll be working in the weather directory, in the script.js.

Assignment

  1. Complete the event listener
    • When the submit button is clicked, get value of the input.
    • Then invoke the makeCall() function with the zip code as an argument.
  2. Fill in the makeCall() function
    • Look at the Open Weather API Documentation
    • This function has the zip code as a parameter.
    • It will construct the url you will use for your Ajax call. HINT:
      The url will look something like: http://api.openweathermap.org/data/2.5/weather?q=[ZIP CODE GOES HERE],us?units=imperial&appid=[PUT YOUR API KEY HERE]
      
    • Then it will preform an AJAX GET request and invoke getData() with the response data.
  3. Finish the getData() function
    • This function will take the response data and grab the following:
      • City name
      • Current temperature
      • Weather description
      • Min temp
      • Max temp
    • It will then pass these as arguments when invoking the appendToDom() function.
  4. Complete the appendToDom() function
    • This function will take each of these parameters and create appropriate elements for each.
    • It will then append the elements to the DOM.

Here are some zip codes to test!

  • 99501 (Anchorage)
  • 99723 (Barrow, AK)
  • 60605 (Chicago)
  • 70124 (New Orleans)
  • 77030 (Houston, TX)
  • 00902 (San Juan, Puerto Rico)
  • 46923 (Delphi, IN)
  • 94123 (San Francisco, CA)

BONUSES!!

  • Add the latitude and longitude, humidity, precipitation, and wind speed
  • Style your app more! Make it look pretty! Some advanced styling ideas:
    • Have the temperature turn blue if under 40, and red if above 90.
    • Look into the javascript date object and change the background color based on the time of day.
  • Look into Font Awesome and add icons based on the weather.

Submission

Homework is due by tonight at midnight

hw-w07d03-fetch-weather-2's People

Contributors

jackiecasper avatar trevorpreston avatar drisdon avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.