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.js Basics (2014) Building a Command Line Application Making a GET Request with http

William Curry
William Curry
4,107 Points

[RESOLVED] SyntaxError: Unexpected token :

Why?

/home/treehouse/workspace/app.js:12
var request = https.get(https://teamtreehouse.com/" + username + ".json", func
(^ points to the ":" in https://)
SyntaxError: Unexpected token :
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3

//problem: we need a simple way to look at a user's badge count and JS points
//solution: use node.js to connect to Treehouse's API to get profile information to print out
var https = require("https");
var username = "williamcurry2";

function printMessage(username, badgeCount, points){
  var message = username + " has " + badgeCount + " total badge(s) and " + points + " points in JavaScript";
  console.log(message);
}

//connect to the API URL (http://teamtreehouse.com/username.json)
var request = https.get(https://teamtreehouse.com/" + username + ".json", function(response){    
                       console.dir(response);
                       //read the data
                       //parse the data
                       //print the data
});
William Curry
William Curry
4,107 Points

Found it. Missing " on line 12, column 25.

1 Answer

Steven Parker
Steven Parker
215,954 Points

Yay! You get a :star: for resolving your own issue!

Now you might want to edit your title and add [RESOLVED] at the beginning as an alternative to selecting an answer.