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 trialja zeker
Courses Plus Student 819 Pointshttp.get doesnt work [error]
var http = require("http");
var username = "chalkers";
function printMessage(username, badgeCount, points) {
var message = username + " has " + badgeCount + " total badges and " + points + " points in javascript";
console.log(message);
}
var request = http.get("http://teamtreehouse.com/" + username + ".json", function(response) {
console.log(response.statusCode);
});
request.on("error", function(error) {
console.error(error.message);
});
This is my code and I dont see anything wrong with it. I get this error message:
treehouse:~/workspace$ node app.js
events.js:72
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND
at errnoException (dns.js:37:11)
at Object.onanswer [as oncomplete] (dns.js:124:16)
treehouse:~/workspace$ node app.js
getaddrinfo ENOTFOUND
treehouse:~/workspace$ node app.js
^[[24~getaddrinfo ENOTFOUND
Am i missing something?
5 Answers
Colin Bell
29,679 PointsHmm. I copied and pasted your exact code into a workspace, and it logged a 200 (it worked).
Try closing the workspace and reopening it. There might be something wrong with the port.
Øyvind Lillegårdsetre
6,273 PointsClick on the "workspaces"-tab on the lefthand side and create a brand new workspace with nodejs environment. That worked for me.
Øyvind Lillegårdsetre
6,273 PointsDid get the same problem. Opening a new workspace did not help, but when i switched to Safari; it worked! Usually use Chrome.
Andres Carbo
19,164 Pointssame problem, still no solution for me even after trying on Chrome, Firefox and Safari. I'm running linux if that matters. I think it's a workspace bug.
Andres Carbo
19,164 Pointsmaybe it's because we don't have profile photos hahaha. Only joking
Matt Gregg
1,752 PointsI'm having the same issue. I did the first part of the course fine and was receiving statusCode 200s. I left and came back a half day later and now I'm running into getaddrinfo ENOTFOUND errors. I tried reopening workspace as well as changing browsers from Chrome to Safari. Nada.
ja zeker
Courses Plus Student 819 Pointsja zeker
Courses Plus Student 819 PointsYes, now i restarted it and it works. It seems like teamtreehouse doesnt work well in google chrome, I found several more quirks.