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 trialJacob Bender
15,300 PointsStatus code 302
My status code response is 302, not 200. I think this has something to do with url redirecting? The explanations I found on google are either very technical or unhelpful.. Thanks.
Jacob Bender
15,300 PointsIn the video he gets response 200, so I am wondering why I a getting 302's.
When I run the code, I get:
302
BODY: <html><body>You are being <a href="https://teamtreehouse.com/404">redirected</a>.
</body></html>
instead of the info I am trying to get.
Update: Never mind, I am an idiot. had a typo in the url request.
Ekaterina Tokareva
5,310 PointsI've noticed, that when in get url I'm writing "http://teamtreehouse.com/" + username + ".json" - the response.statusCode is 200. And in case of "http://www.teamtreehouse.com/" + username + ".json" url value the response.statusCode is 301
2 Answers
Zain Mustafa
5,301 Points@ekaterinatokareva2 i'm also having the same response from the server.
Winthrop Granville
24,373 PointsMake sure you are requiring https (NOT http), like so:
var http = require("https"); //this is correct
Likewise, make sure you are using the https url and NOT http:
var request = http.get("https://teamtreehouse.com/" + username + ".json", function(response){
console.log(response.statusCode);
});
That should give you the 200 response.
Mark VonGyer
21,239 PointsMark VonGyer
21,239 PointsI don't see the question. Yes 300's are relevant to redirects.