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 Build a Simple Dynamic Site with Node.js Handling Routes in Node.js Populating User Information

jsdevtom
jsdevtom
16,963 Points

SOLVED: Cannot read property '404' of undefined / Other errors.

treehouse has shamefully, after many months, still not updated the project files to reflect their update to https. Basically if you do not do the following, your code will not work:

  • In the file profile.js, you need to require both http and https. You need to require http for the reason that STATUS_CODES is one of the few things node's https doesn't replicate from http, and using https in it's place here is causing the error.
var https = require("https");
var http = require("http");
  • Thus in order to access the STATUS_CODES object, you will need to change a section of the line at 24 (under the comment "//Status Code Error") from
https.STATUS_CODES

to

http.STATUS_CODES
    var request = http.get("http://teamtreehouse.com/" + username + ".json", function(response) {

to

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

If I've forgotten something, please tell me :-)

This worked for me. Thanks for the code fixes. I've found this same http/https issue in a few JavaScript courses. I wonder if TreeHouse is intentionally not fixing it in hopes of students learning to solve the problem themselves.