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

Floyd Orr
Floyd Orr
11,723 Points

I get stuff like:app.js:at objecct.Module._extensions..js (module.js:474:10) but no error code. My code is not working?

// Problem: We need a siple way to look at a user's badge count and javascript points
// use node.js to connect to Treehouse's API to get profile information to print out
var http = require("http");
var username ="floydorr";

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

}

//1connect to the API url (http:// teeamtreehouse.com/
var request = http.get("http://teamtreehouse.com/" + username +" .json", function (response) {
                console.log(reponse.statusCode);                                                                 
  //2read the data
    reponse.on( "data", function (chunk) {
        console.log("BODY: " + chunk);  

        });


    );
//3Parse the data
//4Print the data

});

2 Answers

jrabello
jrabello
17,917 Points

Hello,

Your code got 2 errors, the first one: 1 - you typed reponse instead of response 2 - unecessary "});"

Clean this and your code should run ok

Floyd Orr
Floyd Orr
11,723 Points

Thank you i got it working 2 days ago