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 trialShari Girten
5,371 PointsIs there a reason why I am getting a statusCode 301 in the Node.js Basic course?
I am attempting to make a http request to see the badge count and I receive a statusCode of 301 with a statusMessage 'Moved Permanently'. This result will not let me receive the data I need to do a JSON parse on the result set.
4 Answers
Roy Penrod
19,810 PointsTreehouse moved all of their urls from http to https a while back. Just switch to using the code for https instead of http and it will work.
Lucas Lu
3,099 PointsHi Shari, I wrestled with this issue a long time, what eventually work for me was:
- change
JavaScript var http = require("http");
to
var http = require("https");
- Change
JavaScript var request = http.get("http://teamtreehouse.com/" + username + ".json", function(response)
to
var request = http.get("https://teamtreehouse.com/" + username + ".json", function(response)
Hope that helps!
Vincent DUBROEUCQ
61,690 PointsI tried it but it still doesn t work. I get a content length greater than 0 but I still get the 301 code
Vincent DUBROEUCQ
61,690 PointsEven with the https require and https.get method, I still get a domain of 'http://team...' instead of https. The url is well written in the code.
Roy Penrod
19,810 PointsIt's been a couple months since I completed the course. If it's not working now, Treehouse might have changed something else on the back-end. Try asking the question again here in the forum and letting them know you already tried this solution and the exact problem you're having now.
If that doesn't work, contact Treehouse support directly.
I know it's frustrating. Hang in there. It's good practice for a career in web development. :-)
Facundo Diaz
10,188 Pointsonly change http for https... in the variable to. sorry but my english i am from argentina
Nathan Monte
16,643 PointsNathan Monte
16,643 PointsLifesaver. Its worth noting that you need to change everything (the variable name/the require/the url).