Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Petar Karagenov
Petar Karagenov
8,608 Points

The readableQuery const

The url Andrew Chalkley uses does not do what is shown on the video. The url given in the documentation looks like this: http://api.wunderground.com/api/${key}/conditions/q/CA/San_Francisco.json - it includes a state. So now the get function requires one more property and also gives the part //const query = process.argv.slice(2).join("").replace(' ', '');// a serious issue. I am stuck with that.

Hi Petar , I had the same problem and fixed it by using:

var state = process.argv.slice(2)[0];
var city = process.argv.slice(3);

var queryString = `https://api.wunderground.com/api/${api.key}/conditions/q/${state}/${city}.json`

and giving the function the two arguments:


I admit it is not very elegant, maybe someone found a prettier solution ?

nico dev
nico dev
20,364 Points

Great answer!

If I could, I'd vote it best answer definitely!

1 Answer

With destructuring assignment, you can also do this:

const [,, state, city] = process.argv;

var queryString = `https://api.wunderground.com/api/${api.key}/conditions/q/${state}/${city}.json`;