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 Node.js Basics 2017 Create a Command Line Weather Application Retrieving Data - Solution

Ceil-Ian Maralit
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Ceil-Ian Maralit
Front End Web Development Techdegree Graduate 19,434 Points

Where did the URL came from?

Hi! I took a look at the URL of this video(https://api.openweathermap.org/data/2.5/weather?) in the teachers notes and when I typed it in with my API key, it threw me an error. I tried slicing the URL to like https://api.openweathermap.org/data, and it threw a 404 status code. I was thinking if the URL they used was still valid?

1 Answer

andren
andren
28,558 Points

The URL comes from the official current weather API documentation. And the URL shown is still the most current version available. The documentation provides info and examples on how to use the API so reading through some of it might help resolve your issue.

I just made a test query using my own key and it worked fine. What error message were you getting and what was the query? If you post the exact URL you used (with the appid redacted of course) then I might be able to point out your issue.

Ceil-Ian Maralit
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Ceil-Ian Maralit
Front End Web Development Techdegree Graduate 19,434 Points

Hi! Yes, you have a point since the error was saying "weather.get is not a function". Thanks. What I did now is try to copy paste it for testing but it did not work for me. I got the code from here: https://teamtreehouse.com/library/retrieving-data-solution, if you may take a look maybe you have a different solution. Thank you so much! (I'm doing this on my PC, by the way.)

andren
andren
28,558 Points

That's strange. I also copy pasted the code from that page and it worked fine for me (I'm also running it on my local machine).

That error suggests that the get function is not exported from the weather.js file properly. Are you sure you have pasted in the right code and saved it? Many editors like Visual Studio Code will show you the code you pasted in and keep it between restarts of the program even if you forgot to actually save the file, which has lead me to accidentally not save files before which has lead to similar issues on my projects.

If you are certain you pasted the code in correctly and saved it then I really don't know what the issue is.

Ceil-Ian Maralit
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Ceil-Ian Maralit
Front End Web Development Techdegree Graduate 19,434 Points

Yeah, I also thought that it is really strange, but I guess I have to move on since I understand that topic now. Thank you so much for the help though!

Best, Ceil