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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Alex Villanueva](https://secure.gravatar.com/avatar/d32a0b1bce26a3433eb9f6d4b30f1961?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Alex Villanueva
3,063 PointsError getting the profile
This is for course Build a Simple Dynamic Site with Node.js
I've spent at least 3 hours on this and would greatly appreciate any help you could give.
var Profile = require("./profile.js"); is included at the top. profile.js is included and has not been edited. I am checking usernames that do exist.
Error given is There was an error getting the profile for alexvillanueva.
function user(request, response) {
var username = request.url.replace("/", "");
if(username.length > 0) {
response.writeHead(200, {'Content-Type':'text/plain'});
response.write("Header\n");
var studentProfile = new Profile(username);
studentProfile.on("end", function(profileJSON){
var values = {
avatarUrl:profileJSON.gravatar_url,
username:profileJSON.profile_name,
badges:profileJSON.badges.length,
javascript:profileJSON.points.JavaScript
}
//Simple Response
response.write(values.username + " has " + values.badges + " badges \n");
response.end('Footer\n');
});
studentProfile.on("error", function(error){
response.write(error.message + "\n");
response.end('Footer\n');
});
}
}
1 Answer
![Mark Sebeck](https://uploads.teamtreehouse.com/production/profile-photos/6569772/micro_mark.jpg)
Mark Sebeck
Treehouse Moderator 37,777 PointsHi Alex. When asking questions it is helpful to link to the video you are working on and also to post all of your code. I assume you are on this video. If so if you look at the question about this video you will see Steve's answer about the link on treehouse for profiles changing. if you change profile.js to this it should work.
var request = https.get("https://teamtreehouse.com/profiles/" + username + ".json", function(response) {
Hope this helps and good luck. Post back to the community if you are still stuck.