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

Nick Trabue
PRO
Nick Trabue
Pro Student 12,651 Points

Error: connect ETIMEDOUT

I've been having a lot of issues with this final piece. I tried to write my own to know avail so I ended up watching and copying what Andrew did unfortunately I'm getting this:

treehouse:~/workspace$ node app.js 90210                                                                       
events.js:160                                                                                                  
      throw er; // Unhandled 'error' event                                                                     
      ^                                                                                                        

Error: connect ETIMEDOUT 8.5.1.38:443                                                                          
    at Object.exports._errnoException (util.js:1022:11)                                                        
    at exports._exceptionWithHostPort (util.js:1045:20)                                                        
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1087:14)   

Weather.JS file

const http = require ('http');
const https = require ('https');
const api = require('./api.json');

function printWeather (weather) {
  const message = `Current temperature in ${weather.location.city} is ${weather.current_observation.temp_f} F`;
  console.log(message);
}
//retreive data
function get(query) {
  const request = https.get(`https://api.wundergrund.com/api/${api.key}/geolookup/conditions/q/${query}.json`, response => {
      let body = "";
      response.on('data', chunk => {
        body += chunk;
      });
      response.on('end', () => {
        //Parase data
        const profile = JSON.parse(body);
        //Print the data
        printWeather (weather);
      });
    });
}
module.exports.get= get;

//TODO: Handle any errors

app.js file:

const weather = require('./weather');
const query = process.argv.slice(2).join("_").replace(' ', '_')
weather.get(query);

Any help would be greatly appreciated. I've been on the strugglebus all morning over this one.