JavaScript Node.js Basics Create a Command Line Weather Application Retrieving Data - Solution

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,332 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.

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,332 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.

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