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!

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 Handling Errors - Solution

Need some assistance..

I am not very good at node.js so far... Not fully understanding the concept of it. Anyway, here's my snapshot of my workspace, i've followed the previous videos and tried to write the code according to them...

I am getting undefined in the console every time I try to pass something... Getting frustrated with this...starting to think that this is not for me...but I don't want to give up, I like the concept of coding, but sometimes it is harder than I expect.

Usually not complaining, just thought I'd share this with someone who feels the same.. Thank you!

3 Answers

Don't be so hard on yourself. Your code actually looks good and you are so close. The only issue was the formatting of the URL. I tweaked it a bit and the following works:

let url = `https://api.openweathermap.org/data/2.5/weather?q=${city}&units=imperial&APPID=${api.key}`;

I looked at the email I got for OpenWeather and used that formatting. You were missing the $ before {} around city and api key. Also I changed the city to q and units to imperial since the output was in Fahrenheit. But you can play around with these. I added the console.log(url) to see how it was formatted and that's how I figured it out. I created a variable url to make it easier to read so you can remove the string from https.get and use the variable shown here:

const request = https.get(url

Also you API key is something you should keep private, otherwise others might use it. Normally this is something you would not check into GIT. And let the tester use their own API Key. So if possible, delete this from your workspace. Good luck and keep coding!

Thanks a lot. It works now. Did not get the last part of the comment, not too familiar with GIT. What exactly should I delete, the actual API key?

Glad it's working now. Yes, in the config file replace your key with something like this:


and in the manifest file document that the tester needs to add their key there.

I don't know how exactly I should do that. I just started learning NODE 3 days ago...Not really familiar with all the concepts. Sorry for being a dummy. Basically I did not get the part with manifest file doc.

No worries, I used the wrong terminology calling it a manifest. It's actually a readme.md file. You can read about them here:


Not sure how far along you are in your studies, but this file can be created when you create a GitHub project or you can create it manually. You add information in it about your program, like how to run it, configuration and other things.

So your api.json file that you share would have:


and in the readme.md file you would state, before running this code please update the api.json file with you valid API key.

I am familiar with the readme.md file, even though I'm not that close with GIT yet, just did not have a chance to work there.. That makes perfect sense to me now. Thank you again!