Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

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
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,696 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.

That helps. Thank you.