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 trialmatthewshear
9,229 PointsIs anyone else having problems with the Workplaces in the "Node.js Basics" course?
In the video, the teacher is retrieving a JSON file, which I can also receive if I type the URL in my address bar, so the file is there.
Unfortunately, the statusCode of the response is always 301 (file moved) instead of 200 (ok), so I can't actually make any of the things the teacher is doing happen whether I try it in the launched workspace or on my own machine where I have Node installed.
I'll type "node app.js" and it just writes that bad statusCode to the console and errors out.
JavaScript
var http = require("http"); var request = http.get("http://teamtreehouse.com/chalkers.json", function(response) { var responseBody = "";
console.log(response.statusCode);
response.on("data", function(dataChunk) {
console.log('test');
responseBody += dataChunk;
console.log(dataChunk);
});
});
1 Answer
Jennifer Nordell
Treehouse TeacherHi! I believe that between the writing of this module and now, the protocol has been changed from using http to using https (which is a more secure form of http). Try updating your code to use https instead of http. Let me know if this works for you!
matthewshear
9,229 Pointsmatthewshear
9,229 Pointslol.. yep! I just figured that out. Why don't they mention this in the course?! It's more than a little important if you want anything to make sense. Thanks!