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 Build a Simple Dynamic Site with Node.js Handling Routes in Node.js Populating User Information

Carlos Sanchez
Carlos Sanchez
8,900 Points

Error when creating a new Person()

Getting the following error when i enter a username in the browser:

/home/treehouse/workspace/router.js:18
var studentProfile = new Profile(username);
^

ReferenceError: Profile is not defined
at Object.user (/home/treehouse/workspace/router.js:18:32)
at Server.<anonymous> (/home/treehouse/workspace/app.js:6:11)
at emitTwo (events.js:106:13)
at Server.emit (events.js:191:7)
at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:543:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:105:23)
This is my workspace: https://w.trhou.se/tzqxwjju5a Does anyone know why is this happening?

2 Answers

Benjamin Barslev Nielsen
Benjamin Barslev Nielsen
18,958 Points

You are very close.

Line 1 in router.js:

var profile = require("./profile.js");

should be

var Profile = require("./profile.js");

and line 20 in router.js:

studnetProfile.on("end",function(profileJSON){

should be

studentProfile.on("end",function(profileJSON){
Rodrigo Valladares
Rodrigo Valladares
9,708 Points

Wooo! thanks, I've had the same mistake!!

Carlos Sanchez
Carlos Sanchez
8,900 Points

Thanks, that solved it for me. I am new to this perspective, coming from java servlets and spring node is proving to be something else. Thank you now I can move forward with the course.