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
Cristen Hewett
23,811 PointsProfile page only shows username and badges. Avatar & Javascript points are broken
I feel I've followed this pretty closely but when I view a profile I only see the username and badges earned displaying correctly. Avatar is a broken image and Javascript points displays: {{javascriptPoints}} JavaScript points
Here's my user function: function user(req, res) { //if url == "/" && GET var username = req.url.replace("/", ""); if (username.length > 0) { res.statusCode = 200; res.setHeader('Content-Type', 'text/html'); renderer.view('header', {}, res);
//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,
javaScriptPoints:profileJSON.points.JavaScript,
}
//Simple response
renderer.view('profile', values, res);
renderer.view('footer', {}, res);
res.end();
});
// on "error"
studentProfile.on("error", function(error){
//show error
renderer.view('error', {errorMessage: error.message}, res);
renderer.view('search', {}, res);
renderer.view('footer', {}, res);
res.end();
});
}
}
1 Answer
Steven Parker
243,318 PointsSince you see some of the info, this part of the code is probably OK. The issue is likely elsewhere, possibly (but not certainly) in the renderer.
For issues with a complex project like this one, the best way to facilitate a thorough analysis and accurate answer is by making a snapshot of your workspace and post the link to it here.
Cristen Hewett
23,811 PointsCristen Hewett
23,811 PointsThanks for taking a look...I had been doing all the work on my desktop hoping to understand it better but when transferring everything to the workspace, I realized it was the profile.html file that was wrong.
I had no value for
and my javaScriptPoints had a lower case S.
changed
Problem solved. thanks again!