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 trial

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

Error while executing the statuscode

Hello there , I have this piece of code running and I would like to know what exactly is not making it run.

I can't spot the error and also previously while executing it , it gave me an error message.

Thank you all!

const https = require("https")

const username = "chalkers" function printMessage (username, badgecount , point){

const message = ${username} has ${badgecount} total badge(s) and ${point} points in Javascript; console.log(message)}

const request = https.get(https://teamtreehouse.com/${username}.json, response => {

                      console.log(response.statusCode)}

1 Answer

Brenden Seidel
Brenden Seidel
16,890 Points

David, I'd be glad to help. First, just a quick tip -- please use markdown to format your code in these comments -- makes it a lot easier to read :)

First, it looks like your function printMessage starts on the same line as your assignment for the username const. Either put the function on a new line (preferred) or add a semi-colon after "chalkers"

const username = "chalkers";
function printMessage (username, badgecount , point) {

Second, it looks like you're trying to create a template literal with the message const. Make sure to wrap that in back-ticks (). The same applies to the URL in thehttps.get()`` call.

const message = `${username} has ${badgecount} total badge(s) and ${point} points in Javascript`; 
`https://teamtreehouse.com/${username}.json`

Lastly, it looks like you're missing a right parentheses at the end of your https.get() call.