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 trialRey Serantes
5,900 PointsI still get a 301 error. Obviously folks have encountered this before. Does anyone have a workaround for this issue?
Here's my code: var request = http.get("http://teamtreehouse.com/" + username + ".json", function(response){ console.log(response.statusCode); //Read the data response.on('data', function (chunk){ console.log('BODY: ' + chunk);
}); //Parse the data //Print the data });
3 Answers
Kevin Korte
28,149 PointsTry it and check, but I think the URL now has to be https
instead of just http
like the video shows. I think that's the fix. But let me know, I haven't done that course in forever.
Rey Serantes
5,900 PointsKevin Korte so I concluded it's due to the username. For some reason when I try to pull the data associated with my profile it returns a not found result but when I run "Chalkers" as the username then it spits out all the JSON data. I feel that the issues is a result of authentication failing. Thoughts?
Kevin Korte
28,149 PointsI agree, I think your user profile is private, I can't click on it. So that might be way it's not finding it. When I replace your username with mine, your code works.
You don't have to do this, but I bet the problem is in your account settings, the "allow everyone to see your profile" is probably unchecked. I bet checking that will fix this.
Rey Serantes
5,900 PointsKevin Korte that was it! Thanks again!
Kevin Korte
28,149 PointsAwesome, no problem.
Rey Serantes
5,900 PointsRey Serantes
5,900 PointsHi Kevin,
For some reason it keeps spitting out Body: not found.
Here's the code I have:
Kairos F
19,925 PointsKairos F
19,925 PointsChanging two lines of code:
var https = require("https");
and
var request = https.get("https://teamtreehouse.com/" +
".... etc...made it go from a 301 to a 200 for me.