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 trialChristoph Walpert
3,752 PointsGetting Unhandled error
Hi, on making the http request i get this error message, when I run my code in the console:
treehouse:~/workspace$ node app.js
events.js:160
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND teamtreahouse.com teamtreahouse.com:80
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:79:26)
And this is my code:
// Problem: We need a simple way to look at a user's badge count and JavaScript points
// Solution: Use Node.je to connect to Treehouse's API to get the Profile information to print out
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);
};
// Connect to the API URL
var request = http.get("http://teamtreahouse.com/"+ username +".json", function(response) {
console.dir(response);
});
// Read the data
// Parse the data
// Print the data
Thanks for the help :)
1 Answer
Tommaso Poletti
5,205 PointsFor Get the 200 in console you must change this two things:
the http variables
var https = require("https");
and in the request:
var request = http.get("https://teamtreehouse.com/" + username + ".json", function(response) {
console.log(response.statusCode);
});
Because the site is now on https ;)