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!

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 2017 Building a Command Line Application Making a GET Request with https

7,768 Points

Why am I getting a statusCode response of "404" instead of "200"?

I saw the other response to the same question, however I am using backticks and still receiving 404. Going to the URL directly works, so why is the statusCode still 404?

const https = require('https');

const username = 'ohtanya';

const request = https.get(`https://teamtreehouse.com/${username}.json`, (res) => {

3 Answers

28,554 Points

Do you have your profile set to private? I can't access your account though that URL either. Try going to the Privacy Settings and make sure the "Allow everyone to see your profile" checkbox is checked. If that is unchecked then your account will only be visible to yourself while logged in.

Since the NodeJS request does not include any login cookies the request will look like a regular non-logged in user, so the account has to be publicly accessible for the code to work.

Per Karlsson
Per Karlsson
12,683 Points

What @andren said. It's also easy to check if your profile is available by just pasting


in the URL bar.