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 trialChris Reich
15,163 PointsHaving problems connecting to Treehouse. .
I am getting this error.
treehouse:~/workspace$ node app.js
/home/treehouse/workspace/app.js:9
var request = http.get("teamtreehouse.com/" + username + ".json"), function(re
^^^^^^^^
SyntaxError: Unexpected token function
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
treehouse:~/workspace
With this code.
function printMessage(username, badgeCount, points) { var message = username + ' has ' + badgeCount + ' badges and ' + points + ' points.'; console.log(message); }
var http = require("http"); var username = "Chris Reich";
var request = http.get("teamtreehouse.com/" + username + ".json"), function(response) { console.dir(response);
});
3 Answers
Colin Marshall
32,861 PointsThe teacher's notes under this previous video note a recent change in the Treehouse API:
Getting Error 301?
On October 20th 2015, we upgraded our website to only use HTTPS rather than just HTTP. This mean more security for anyone using our site. This does include some breaking changes to our code. But it's simple to fix. Replace any references to http to https. For example:
var https = require("https");
Modify any links from "http://teamtreehouse.com/" to "https://teamtreehouse.com/".
Craig Garner
25,732 PointsYour username also has a space in it.
isral duke
7,315 PointsI figured something like this was happening. Earlier, before my Treehouse courses, i would have simple moved on. I still needed your help to fix it, but thanks for the learning and the help!