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 Handling Errors in Node

JT Keller
JT Keller
12,731 Points

Workspace Error Message Different from Mac Terminal or IntelliJ

I'm just curious as to why my code works when using the workspace provided by Treehouse, but when I run the same code on Terminal in Mac or on IntelliJ, I get the standard stack trace response. I changed the http object to an https object based on the site's changes. I can connect with a 200 response when the URL is correct.

var https = require("https");
var username = "jtkeller";

function printMessage(username, badgeCount, points) {
    var message = username + " has " + badgeCount + " total badge(s) and " + points + " points in JavaScript";
    console.log(message);
}

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

request.on("error", function (error) {
    console.error(error.message);
});