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 trialThomas Katalenas
11,033 PointsprofileJSON?
profileJSON is a built in method or what, where did it come from.
function userRoute(request, response) {
var username = request.url.replace('/', "");
if(username.length > 0) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.write('Header\n');
//get json from Treehouse
var studentProfile = new Profile(username);
//on end
studentProfile.on("end", function(profileJSON){
// show profile
//Store the values which we need
var values = {
avatarUrl: profileJSON.gravatar_url,
username: profileJSON.profile_name,
badges: profileJSON.badges.length,
javaScript: profileJSON.points,
}
});
Abraham Juliot
47,353 PointsAbraham Juliot
47,353 PointsHi Thomas, the parameter (represented by "profileJSON") is built into the "on" method, which is built into the new "Profile" object. The parameter "profileJSON" can be named anything, but it must receive an argument via the callback function argument sent by the built in "on" method.