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

Getting 404 error when calling response.statusCodes

Hey all! I changed references from http to https. However, I am still getting 404 response codes and I'm not quite sure why. Here is the code I have so far:

//Problem: We need a simple way to look at a user's badge count and JavaScript points //Solution: Use Node.js to connect to Treehouse's API to get profile information to print out var https = require("https");

var username = "chalkers"; function printMessage(username, badgeCount, points) { var message = username + " has " + badgeCount + " total badge(s) and " + points + " points in JavaScript"; console.log(message); } //Connect to the API URL (https://teamtreehouse.com/username.json) var request = https.get("https://teamtreehouse.com/username.json" + username + ".json", function(response){ console.log(response.statusCode); }); //Read the data //Parse the data //Print the data

Any ideas?

2 Answers

Thomas Nilsen
Thomas Nilsen
14,957 Points

Your URL looks like this:

"https://teamtreehouse.com/username.json" + username + ".json"

when it should look like this:

"https://teamtreehouse.com/" + username + ".json"

Awesome thanks Thomas!