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

A A
A A
Full Stack JavaScript Techdegree Student 19,812 Points

SyntaxError: Unexpected token N

I'm getting an unexpected syntax error and I'm not sure why. When I execute the file in node.js with the const username, it retrieves the data, but when I comment the username out and add usernames with "" as a argument, it's giving me an error.

Any suggestions?

const https = require('https'); const username = "nickolasteixeira"; //This would be a static program, because we are tied to our username variable, just 1 variable

// Function to print message to console function printMessage(username, badgeCount, points) { const message = ${username} has ${badgeCount} total badges(s) and ${points} points in Javascript; console.log(message); }

function getProfile(username) {

// Connect to the API URL (https://teamtreehouse.com/username.json) var request = https.get(https://teamtreehouse.com/${username}.json, response => {

var body = "";
//Printing out the status code to see if the url was able to connect
// console.dir(response.statusCode);
// Read the data
response.on('data', (data) => {
  body += data.toString();
  // process.stdout.write(data);
});

response.on("end", () => {
  // Parse the data
  // to figure out the type of object
  // console.log(typeof body);

  const profile = JSON.parse(body);
  // Print the data
  // console.dir(profile); OR
  printMessage(username, profile.badges.length, profile.points.JavaScript);
});
//String to a data structure is called parsing.

}); }

getProfile(username); // getProfile("nickolasteixiera"); // getProfile("chalkers");

A A
A A
Full Stack JavaScript Techdegree Student 19,812 Points

Sorry, I meant if you put any username in the parenthesis. For example -> "nickolasteixeira"

Steven Parker
Steven Parker
170,273 Points

I'm a bit confused about when you "comment the username out" .. how would the username variable get set then?