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

shirshah sahel
shirshah sahel
10,035 Points

I did'nt understand this is very well.

Can someone please explain how to pass this challenge?

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


   response.on("data", function(dataChunk) {
      responseBody += dataChunk;
    });


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

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

1 Answer

Steven Parker
Steven Parker
231,210 Points

You've actually done what the challenge asked for. But you also apparently tried to convert the callback syntax from the arrow function style to the conventional style, and didn't quite get the syntax right.

Converting the function style isn't part of the challenge. I suggest starting over and doing only what the instructions ask for (just a one-liner for each task).