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

Catalina Villalonga
Catalina Villalonga
5,163 Points

Without renaming any of the variables, modify the data callback to concatenate the stream of data to the responseBody

I dont understand what I am doing wrong

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

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

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

});

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

2 Answers

Steven Parker
Steven Parker
187,484 Points

You have a spelling error, "dataChuck" instead of "dataChunk" (with an "n").