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 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 (https://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
231,275 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.