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 trialFrancis Hong
3,663 PointsError getting profile
Error: There was an error getting the profile for chalkers. (Moved Permanently)
Seems that it redirects to https for getting the JSON for profile information.
3 Answers
Sean Henderson
15,413 PointsTo fix this bug in my workspace I had to require both the http
and https
modules and change everything in profile.js
to https except for http.STATUS_CODES
:
var EventEmitter = require("events").EventEmitter;
var http = require("http");
var https = require("https");
var util = require("util");
[...]
//Connect to the API URL (https://teamtreehouse.com/username.json)
var request = https.get("https://teamtreehouse.com/" + username + ".json", function(response) {
var body = "";
if (response.statusCode !== 200) {
request.abort();
//Status Code Error
profileEmitter.emit("error", new Error("There was an error getting the profile for " + username + ". (" + http.STATUS_CODES[response.statusCode] + ")"));
}
[...]
Julian Aramburu
11,368 PointsFrancis! Treehouse implemented HTTPS on their website! So you must change your http request and ajax calls to https in order for them to work properly :)! Hope it helps!
Chyno Deluxe
16,936 Points//Changed comment to answer
Nejc Vukovic
Full Stack JavaScript Techdegree Graduate 51,574 PointsJust to add: I was using the 8080 port to listen to -> didn't work :)
Changed it to 3000 and booyah it worked...
Tom Sharon
1,478 PointsTom Sharon
1,478 PointsThanks Sean Henderson! That did the trick.