JavaScript Node.js Basics Building a Command Line Application Getting the Response Body

Cynthia Smith
Cynthia Smith
8,031 Points

unexpected end of input

I can't ask my question in 120 char

app.js
const https = require("https");
const request = https.get("https://teamtreehouse.com/chalkers.json", response => {
    let responseBody = "";

     response.on("data", function(dataChunk) {

       responseBody = responseBody + dataChunk;
     });

response.on("end", function(){
    console.log(responseBody);
});

request.on("error", error => {
    console.error(error.message);
});

2 Answers

Brendan Whiting
MOD
Brendan Whiting
Front End Web Development Treehouse Moderator 84,071 Points

You're missing a closing }); which would fall on line 17 at the end of the file. Lines 10-end in your code are also not indented properly.

Most text editors, IDE's will help you avoid these kinds of errors by automatically generating closing braces, and by flagging errors with squiggly red underlines. The treehouse challenge online environment doesn't have a lot of those features, so sometimes it helps to work out the code in your own text editor, but that's not always possible.

Cynthia Smith
Cynthia Smith
8,031 Points

That helps. Thank you.