Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

ohtanya
7,768 PointsWhy 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) => {
console.log(res.statusCode);
});
3 Answers

andren
28,520 PointsDo 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
12,683 PointsWhat @andren said. It's also easy to check if your profile is available by just pasting
https://teamtreehouse.com/ohtanya.json
in the URL bar.

ohtanya
7,768 PointsThank you!