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 Making a GET Request with http

Karl M
Karl M
14,111 Points

Get request has all https references however still error 301 appears?

Here is my code below, i still receive error message 301 even after converting to everything to "https" !? Need some help please :)

https://w.trhou.se/s2p0mn6f9t

2 Answers

If you remove the www. part from the URL, you'll get 200.

https.get("https://teamtreehouse.com/" + username + ".json", function (response){
Karl M
Karl M
14,111 Points

Thanks a million Dino! Two heads are better than one.

//Full answer: Need to fetch and reference the https module, not the http one per the video

var https = require("https");

var request = https.get("https://teamtreehouse.com/" + username + ".json", function(response){ console.log(response.statusCode);