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 trialRichard Brown
6,950 PointsThis is a poor course.. and what am I missing?
Hi all.
Firstly, this course is really poor. I have liked Andrews teaching methods in previous courses, (although as a fellow Englishman, I wish he'd say 'roots' instead of 'rowtes' :D).
I have followed through the course so far, and have answered the questions easily, but sometimes I find that I haven't understood the last 2 minutes of what Andrew is saying. But I am hoping that if I watch this course several times, I will pick up more from each viewing.
I have found that this course, in many places, I am typing and looking at my output, and listening to Andrew who isn't saying everything he does. (ie: in one video he says "and if we look into our RENDERER file", whilst he opens the ROUTER file. And each amendment to the code is fast, and not necessarily explained correctly (ie: "you may need to delve deeper into this").
But here is where I am stuck. This is my code (run locally from my machine, ie. not using workspaces):
function home(request, response){
if(request.url === "/"){
if(request.method.toLowerCase() === "get"){
response.statusCode = 200;
response.setHeader('Content-Type', 'text/html');
renderer.view("header", {}, response);
renderer.view("search", {}, response);
renderer.view("footer", {}, response);
response.end();
}else{
request.on("data", function(postBody){
let query = queryString.parse(postBody.toString());
response.write(query.username);
response.end();
});
}
}
This function throws this error:
$ node app.js
C:\Users\Admin\Dropbox\Web Design\TreeHouse\NODE.js\dynamic-site\router.js:109
});
^
SyntaxError: Unexpected token )
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\Admin\Dropbox\Web Design\TreeHouse\NODE.js\dynamic-site\app.js:4:14)
Any suggestions, please?? I'm sure it is just a "typo", but i "cannot see the wood for the trees"..
Thanks in advance
2 Answers
Ari Misha
19,323 PointsHiya there! Whenever im learning anything, i rely more on documentations than treehouse videos. I consider theses vids as vids for creating some project. Anyways your console is telling you that there is a Syntax error in your router.js file. In your home function , you've two nested if conditionals, and you pretty much forgot to close your second if conditional. I hope it helped!
~ Ari
Jack Hou
3,731 PointsIt can get pretty intimidating sometimes when you see errors. But personally I'm loving this course. You have a typo, it's not a big deal. Fix it and you should be fine.