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 trialohtanya
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,558 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!