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 Node.js Basics (2014) Building a Command Line Application Getting the Response Body

Nadine Schermerhorn
Nadine Schermerhorn
2,324 Points

Having trouble with the "Getting the Response Body" video. My workspace doesn't come return the body.

My workspace isn't responding the same as the video. It doesn't appear to be going through the response.on function section since I can't console.log anything out of it. Help//Problem: We need a simple way to look at a user's badge count and JavaScript points

//Solution:  Use Node.js to connect to Treehouse's API to get profile information to print out
var username = "chalkers";
var http = require("http");
function printMessage(username, badgeCount, points) {
  var message = username + "has " + badgeCount + " total badge(s) and " + points + " points in JavaScript";
//printMessage("Chalkers", 1000, 2000);
//Connect to the API URS (http://teamtreehouse.com/username.json)
var request = http.get("http://teamtreehouse.com/" + username + ".json", function(response) {
    response.on('data', function(chunk) {  //Read the data
        console.log('BODY: ' + chunk);


//Parse the data (bring the data from a string into program friendly way of interacting with it)
//Print the data

request.on("error", function(error) { //using on method to listen for an error event


1 Answer

Joel Kraft
Joel Kraft
Treehouse Guest Teacher

Hi Nadine,

This is probably an issue with the api, which is now served over https instead of http. See the accepted answer to this post, and let us know if that solves it for you.