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

I am getting a 404 "Not Found" error in the console. What am I doing wrong?

I am trying to connect to the Treehouse API. I am following the video correctly I think but I am still getting a 404 error. I know that I am missing something small here. Any directional help would be greatly appreciated.

// 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 a message to the 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', (res) => {
    console.log('statusCode: ', res.statusCode);
    //read the data
    //parse the data
    //print the data


2 Answers

I have answered my own question. Took me a while but I figured out that I was using " ' " in stead of the " ` " in the URL for the GET request.

Rodrigo Valladares
Rodrigo Valladares
9,708 Points

hey thanks for post your own question but how do that " ` " what is the keyword ??

That is the back-tick character: ` It is located to the left of the "1" key. In ES6 we can use template strings. This allows us to concatenate much easier in JavaScript.