Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Parsing Data and Printing - Solution1:14 with Andrew Chalkley
In this video I'll show you how I parsed the data and printed in to the console.
At the top of the weather.js file, I've implemented a printWeather function
that takes in a JSON object returned from the API and prints out this city,
And the temperature in Fahrenheit.
The reason I'm getting the city from the location, rather than the query inputted
by the user, is that if a user is to put in a zip code and
made a slight error with one of the numbers, at least they'll see an easily
understandable location to help spot their mistake.
Finally, down in the response, where the end event handler is,
we're parsing the JSON here and printing out the weather location.
Let's see the output in action.
Node app.js 90210.
Awesome, your next challenge is to handle any connection parsing status code and
any other errors that your program might encounter.
Good luck, and I'll share with you my solution in the next video.
You need to sign up for Treehouse in order to download course files.Sign up