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 trial

JavaScript Node.js Basics (2014) Building a Command Line Application Parsing JSON

Shari Girten
Shari Girten
5,371 Points

Is 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
Roy Penrod
19,810 Points

Treehouse 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.

Nathan Monte
Nathan Monte
16,643 Points

Lifesaver. Its worth noting that you need to change everything (the variable name/the require/the url).

Lucas Lu
Lucas Lu
3,099 Points

Hi Shari, I wrestled with this issue a long time, what eventually work for me was:

  1. change JavaScript var http = require("http"); to
var http = require("https");
  1. 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
Vincent DUBROEUCQ
61,690 Points

I 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
Vincent DUBROEUCQ
61,690 Points

Even 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
Roy Penrod
19,810 Points

It'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
Facundo Diaz
10,188 Points

only change http for https... in the variable to. sorry but my english i am from argentina