JavaScript Node.js Basics Building a Command Line Application Capturing Command Line Arguments

How do I fix this error on my code to make it run properly

I Have been Working on this along with the lecture

const https = require('https');


function ptintMessage(username, badgecount, point) {
  const message = `${username} has ${badgecount} total badge(s) and ${point} points in Jscript`;
  console.log(message);
}
function getProfile(username) {
//connect to api url (https://teamtreehouse.com/username.json)

conts request = https.get(`https://teamtreehouse.com/${username}.json`, response => {
    let body = "";
    console.log(response.statusCode);
    response.on('data', data => {
               body + data.toString();
                });

                response.on('end', () => {
                            const profile = JSON.parse(body);
                            console.dir(profile);
                           printMessage(username, profile.badges.length, profile.points.JavaScript);
                            });
               });
}

In the Comand line it says that an error was thrown on the request variable here: conts request = https.get(https://teamtreehouse.com/${username}.json, response => {

Can someone show me what went wrong by chance?

2 Answers

james south
james south
Front End Web Development Techdegree Graduate 33,245 Points

one thing i see is that you misspelled printMessage as ptintMessage when you defined the function.

Nikola Jankovic
Nikola Jankovic
10,793 Points

Misspelled conts request= > const request

Nikola Jankovic
Nikola Jankovic
10,793 Points

body + data.toString(); => body += data.toString();

Nikola Jankovic
Nikola Jankovic
10,793 Points

function ptintMessage => function printMessage