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 trialDanny L.
10,837 PointsWhere 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
https://api.openweathermap.org/data/2.5/weather?APPID=e292b12b35dd3c979543dc91df9e1938&units=imperial&zip=90210%2Cus
{"coord":{"lon":-118.41,"lat":34.09},"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01d"}],"base":"stations","main":{"temp":71.67,"fe
els_like":74.1,"temp_min":66.2,"temp_max":75,"pressure":1016,"humidity":68},"visibility":10000,"wind":{"speed":1.86,"deg":328},"clouds":{"all":1},"dt":16025
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:
app.js
const weather = require("./weather.js");
const query = process.argv.slice(2).join(" ");
weather.get(query)
weather.js
const weather = require("./weather.js");
const query = process.argv.slice(2).join(" ");
weather.get(query)
api.json
{
"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
Sean Paulson
6,669 Pointscheck 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.)