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 trialQuintin Riley
12,136 PointsNode Basic app.js error
When I run app.js in the Node Basics course I get this /home/treehouse/workspace/app.js:31
});
^
SyntaxError: Unexpected end of input
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
So I remove it and I still an error, please help. Here's my code.
// Problem: We need a simple way to look at a user's badge count and JavaScript points // Solution: Use Node.js to connect to Treehouse's API to get profile information to print out //require https module const https = require('https'); const username = "chalkers";
//Function to print message to console
function printMessage(username, badgeCount, points) {
const message = ${username} has ${badgeCount} total badges(s) and ${points} in JavaScript
;
console.log(message);
}
// Connect to the API URL (https://teamtreehouse.com/username.json)
const request = https.get(https://teamtreehouse.com/${username}.json
, response => {
let body = "";
// Read the data
response.on('data', data => {
body += data.toString();
});
response.on('end', () => { //Parse the data console.log(body); console.log(typeof body); //Print the data });
4 Answers
Steven Parker
231,269 PointsMuch easier to see with the formatted code!
So on line 14, there's the beginning of a function call (https.get) and also the beginning of a callback function. But the matching brace for the callback and the matching parenthesis for the call are both missing from the file!
So after line 26, there should be another line that looks just like it.
Quintin Riley
12,136 PointsOk, will do
Quintin Riley
12,136 PointsHere's the screen shot https://w.trhou.se/vc4wm1x9pg
Quintin Riley
12,136 PointsThanks a million, I was going crazy looking at the code.
Steven Parker
231,269 PointsQuintin Riley — Glad to help. You can mark the question solved by choosing a "best answer".
And happy coding!
Steven Parker
231,269 PointsSteven Parker
231,269 PointsIt would help a lot if the code was formatted for the forum with Markdown.
Even better, make a snapshot of your workspace and post the link to it here.