Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 (http://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!