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

Receiving statusCode 404 and body: not found

I am on Node.js Basics "Getting the Response Body". I am receiving a statusCode of 404 and the body is not found.

Here is the code:

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

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", function(response){ //read the data console.log(response.statusCode); response.on('data', function(chunk) { console.log('BODY: ' + chunk); }); //parse the data //print the data });

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

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

At the end of your username you have the semi-colon inside the quotes, making it part of the username. The semi-colon at the end of JavaScript statements is optional, so there won't be a syntax error. Just a typo.

Since it's very unlikely that a user with the profile of randolphgoldsmith; exists, you'll get a 404.