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 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,735 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.