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

Daniel L.
Daniel L.
10,836 Points

Where did querystring come from?

I was following along quite well until we got to the forecast app and all the changes necessary due to weather underground not being available anymore.

My first question with the changes is what is:

const querystring = require("querystring")

What is querystring? Where did it come from how are we requiring it, I have no idea what this means.

As for the app itself. I'm currently at the point where it should work when I run it with a zipcode but this is my result after running node app.js 90210

{"coord":{"lon":-118.41,"lat":34.09},"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01d"}],"base":"stations","main":{"temp":71.67,"fe
19985,"sys":{"type":1,"id":5872,"country":"US","sunrise":1602511002,"sunset":1602552173},"timezone":-25200,"id":0,"name":"Beverly Hills","cod":200}

The information seems to be there but all jumbled up and I don't know what the template literals didn't seem to work.

Here is my full code up to this point:


const weather = require("./weather.js");

const query = process.argv.slice(2).join(" ");



const weather = require("./weather.js");

const query = process.argv.slice(2).join(" ");



  "key": "my key is entered here"

Also, what are .zip and .q? I don't see any zip or q properties in the object that gets returned when I run the code. Where are these properties coming from?

1 Answer

check this out. https://nodejs.org/api/querystring.html#querystring_querystring_stringify_obj_sep_eq_options

They only mention using this in the teachers notes...(I know they need to redo this part of the course.)