JavaScript Node.js Basics Building a Command Line Application Making a GET Request with https

Susan Rusie
Susan Rusie
10,670 Points

Why am I getting "404" instead of "200"?

// 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

//Require https module
const https = require('https');
const username = "chalkers";

// Function to print message to console
function printMessage(username, badgeCount, points) {
    const message = '${username} has ${badgeCount} total badge(s) and ${points} points in JavaScript';

// Connect to the API URL (
const request = https.get('${username}.json', response => {

                        // Read the data
                        // Parse the data
                         //Print the data

Chris Gaona
Chris Gaona
Full Stack JavaScript Techdegree Graduate 31,350 Points

It looks like you're using regular single quotes for your url string and your other strings, but you are trying to use es6 template strings. You should be using backticks, which should be right next to the esc key on your keyboard instead. You're using this:


When you should be using this:


See this link for more details: Hopefully that helps!

Susan Rusie
Susan Rusie
10,670 Points

Thank you, Chris. Making that change to the back ticks fixed the problem.

1 Answer

Daron Anderson
Daron Anderson
1,968 Points

So apparently mines was not working because I used my name, but not the correct username the way the URL formatted the name. So if anyone is using their name, copy and paste your username from the URL into const username = "yourusername"

i was formatting it incorrectly. didn't make sure the name in the URL was the name in the username variable.

Thank you for this!