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

Nick Trabue
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                                                                       
      throw er; // Unhandled 'error' event                                                                     

Error: connect ETIMEDOUT                                                                          
    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 ${} is ${weather.current_observation.temp_f} F`;
//retreive data
function get(query) {
  const request = https.get(`${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(' ', '_')

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