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 trial

JavaScript

Alessandra Vaughn
Alessandra Vaughn
13,915 Points

Issue with node.js and workspaces

I'm on the node.js basics course. I'm a few videos in, where we are using the http.get method. I've been following along, but when I try to execute node app.js in the console, I get "getaddrinfo ENOTFOUND" as a response instead of what the teacher gets. I've looked over my code and can't find anything. Any help would be appreciated.

// Connect to the API URL (https://teamtreehouse.com/username.json)
var request = http.get("http://teamtreehouse.com/alessandravaughn.json", function(response){
  var body = "";
  // Read the data
  response.on('data', function (chunk) {
    body += chunk;
  });
  response.on("end", function(){
    console.log(body);
    console.log(typeof body);
  });
  // Parse the data
  // Print the data
});
request.on("error", function(error){
  console.error(error.message);
});

5 Answers

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

You're code is correct. It works on my local machine but not in WorkSpaces. I've filed an issue and I'll let you know as soon as our Workspaces developer team looks in to it.

Sorry for the inconvenience!

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Hey Alessandra Vaughn

It looks like it's working again. I spoke with our Site Operations and they tested it and it worked. I then tested it again in Workspaces and it worked for me again. It must have been an intermittent network issue.

Try again and let me know if you experience issues again.

Regards Andrew

Hi,

I'm facing the same issue now. The code I'm trying to run is the following:

 var http = require("http");
var username = "chalkers";

function printMessage(username, badgeCount,points){
  var message = username + " has " + badgeCount + " total badge(s) and " + points + " points in JAvaScript";
  console.log(message);
}

var request = http.get("http://www.google.com"/*"http://teamtreehouse.com/"+ username + ".json"*/, function(response){
  console.dir(response); 
});
Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Site Ops have been testing a new Workspace deployment that's just gone live. Can you try it again now?

If you have a Workspace already open, close it for about 15 minutes before trying again.

Thanks for your patience.

Just tried again and it worked fine, thank you!