JavaScript Node.js Basics Create a Command Line Weather Application Parsing Data and Printing - Solution

Julianna Kahn
Julianna Kahn
20,700 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
Sheila Anguiano
20,937 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,700 Points

Thanks so much for clarifing that.