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 Parsing Data and Printing - Solution

Julianna Kahn
Julianna Kahn
20,702 Points

Keep getting the error message: Cannot find module '_/api.json'

https://w.trhou.se/j54tzsvgag

I used require('./api.json'); so I don't understand what that message would be referring to.

Sheila Anguiano
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Sheila Anguiano
Full Stack JavaScript Techdegree Graduate 35,236 Points

Hi Julianna,

When you signed to Openweather to get a KEY, this will be available when you log into your account and click on the API Keys bar, it will be a 33 digit code made of numbers and letters. This is YOUR personal number to get information for your app to get the weather for X location in your request like this:

const request = https.get(https://api.openweathermap.org/data/2.5/weather?q=${location}&APPID=bigLONGnumberISb111111gggg, response => { console.log (response.statusCode);

The reason Chalkers created the module *'./api.json' * is because the API key is sort of a personal number, so you can have your number save in there, but let say that at some point you upload your app, you don't want to share your personal API key and let Openwheather think that you're making a milllion of request to their site, you want other people to get their OWN keys put them in that file and use your APP, so what you do, is use template literals like this

const request = https.get(https://api.openweathermap.org/data/2.5/weather?q=${location}&APPID=${api.key}, response => { console.log (response.statusCode);

1 Answer

Julianna Kahn
Julianna Kahn
20,702 Points

Thanks so much for clarifing that.