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)
![Ben Basty](https://uploads.teamtreehouse.com/production/profile-photos/9866322/micro_profilepic.jpg)
Ben Basty
23,772 PointsI am having javascript Points as undefined on the result page
<ul> <li><span>110</span> Badges earned</li> <li><span>undefined</span> JavaScript points</li> <li><a href="/">search again</a></li> </ul>
i don't know maybe it's a mistake somewhere. Anyone that had the same problem pls let me know how u resolved it.
![Ben Basty](https://uploads.teamtreehouse.com/production/profile-photos/9866322/micro_profilepic.jpg)
Ben Basty
23,772 PointsIt's on the full-stack javascript course. (Build a Simple Dynamic Site with Node.js) I've made it to the "binding values" part. Everything is working perfectly. but i'm getting undefined javascript points when i try to enter any username. here is the link to the result screenshots. https://res.cloudinary.com/benbasty/image/upload/v1529599128/Screen_Shot_2018-06-22_at_12.38.26_AM.png https://res.cloudinary.com/benbasty/image/upload/v1529599128/Screen_Shot_2018-06-22_at_12.38.26_AM.png
And here is the code. App.js
// create a web server
var router = require('./router.js');
var http = require('http');
http.createServer(function(request, response){
router.home(request, response);
router.user(request, response);
//response.end('Hello World\n');
}). listen(3000);
console.log('Server running at http://<workspace-url>');
router.js
var Profile = require("./profile.js");
var renderer = require("./renderer.js");
var commonHeaders = {'Content-Type': 'text/html'};
// handle a http route GET and POST
function home(request, response){
// if url ="/" && GET
if(request.url === "/") {
// show search
response.writeHead(200, commonHeaders);
renderer.view("header", {}, response);
renderer.view("search", {}, response);
renderer.view("footer", {}, response);
response.end();
}
// if url == "/" && POST
// redirect to :/username
}
// handle the http route for GET/: username i.e / chalkers
function user(request, response) {
// if url == "/...."
var username = request.url.replace("/", "");
if(username.length > 0) {
response.writeHead(200, commonHeaders);
renderer.view("header", {}, response);
// get JSON FROM TREEHOUSE
var studentProfile = new Profile(username);
// on "end"
studentProfile.on("end", function(profileJSON){
// show profile
// store the value needed
var values = {
avatarUrl: profileJSON.gravatar_url,
username: profileJSON.profile_name,
badges: profileJSON.badges.length,
javascriptPoints : profileJSON.points.Javascript
}
//Simple response
renderer.view("profile", values, response);
renderer.view("footer", {}, response);
response.end();
});
// on error
studentProfile.on("error", function(error){
// show error
renderer.view("error", {errorMessage: error.message}, response);
renderer.view("search", {}, response);
renderer.view("footer", {}, response);
response.end();
});
}
}
renderer.js
var fs = require("fs");
function mergevalues(values, content) {
for (var key in values) {
content = content.replace("{{" + key + "}}", values[key]);
}
return content;
}
//function that handles the reading of files and merge in values
// read from file an get the strings
// merge value from the string
function view(templateName, values, response) {
// read from the template files
var fileContents = fs.readFileSync('./views/' + templateName + '.html', {encoding: "utf8"});
fileContents = mergevalues(values, fileContents);
response.write(fileContents);
}
module.exports.view = view;
2 Answers
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsThis code isn't complete. it's missing at least one more component named "profile.js".
And a snapshot is a complete clone of your workspace, it makes it easy to replicate the issue. It's not a "screenshot" (which is not very helpful).
![Ben Basty](https://uploads.teamtreehouse.com/production/profile-photos/9866322/micro_profilepic.jpg)
Ben Basty
23,772 Pointsokay i got it. here is the snapshot link http://w.trhou.se/w6pqzja3pa thanks))))
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsOn line 55 of "router.js" you have "profileJSON.points.Javascript" (with lower-case "s") instead of "profileJSON.points.JavaScript" (with capital "S").
![Ben Basty](https://uploads.teamtreehouse.com/production/profile-photos/9866322/micro_profilepic.jpg)
Ben Basty
23,772 PointsThank you so much. :) thanks alot.
Steven Parker
230,688 PointsSteven Parker
230,688 PointsYou would need to show all the code for it to be possible to located the error. The best way is to make a snapshot of your workspace and post the link to it here.