Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Node 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 });

Steven Parker
Steven Parker
220,450 Points

It 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.

4 Answers

Steven Parker
Steven Parker
220,450 Points

Much 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.

Ok, will do

Here's the screen shot https://w.trhou.se/vc4wm1x9pg

Thanks a million, I was going crazy looking at the code.

Steven Parker
Steven Parker
220,450 Points

Quintin Riley — Glad to help. You can mark the question solved by choosing a "best answer".

And happy coding!