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 trialAli Raza
13,633 Points[Resolved]: Syntax Error despite using HTTPs
I am using require('https') yet I am still getting a syntax error: Unexpected Token which I am unable to debug. Can anyone please help? much thanks
//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 the profile information to print out
var https = require("https");
//var username = "aliraza";
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/aliraza.json)
var request = https.get("https://teamtreehouse.com/aliraza.json",function(response){
console.dir(response);
// read the data
// parse the data
// Print the data
})
Getting this error
/home/treehouse/workspace/app.js:9
}]
^
SyntaxError: Unexpected token ]
at Object.exports.runInThisContext (vm.js:76:16)
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.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
Ali Raza
13,633 PointsAli Raza
13,633 PointsIt was "]" type mistake at the end of the printMessage function causing a syntax error.