Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AJAX Basics (retiring) AJAX and APIs Set up the data to pass to the API

Charles Welbeck
PLUS
Charles Welbeck
Courses Plus Student 9,745 Points

The code to this challenge and the other following challenges are not working.

$(document).ready(function() {

  var weatherAPI = 'http://api.openweathermap.org/data/2.5/weather';
  var data = {
    q : "Portland,OR",
    units : "metric"
  };
  function showWeather(weatherReport) {
    $('#temperature').text(weatherReport.main.temp);
  }

});

2 Answers

Dave McFarland
STAFF
Dave McFarland
Treehouse Teacher

Hi Charles Welbeck

What error are you seeing exactly. For the challenge on this page: https://teamtreehouse.com/library/set-up-the-data-to-pass-to-the-api all you are supposed to do is add the data object inside the $(document).ready() function like this:

$(document).ready(function() {
  var weatherAPI = 'http://api.openweathermap.org/data/2.5/weather';
  var data = {
    q : "Portland,OR",
    units : "metric"
  };
});

This code should pass -- I just tried it.

Also, in the next challenge. The code you supplied also passed for me. Please try these again and if you have more problems, please report back the error messages you're receiving.

Sorry for the inconvenience. I'm not sure why your code did not pass.

Dave McFarland
Dave McFarland
Treehouse Teacher

Sorry it didn't work the first time!!!!