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

Need help with getting the response body challenge

I've tried everything I can think of to the code to work but after review the video and documentation, I am still unable to get it to work.

const https = require("https");
const request = https.get("", response => {
    let responseBody = "";

    response.on("data", dataChunk => {


    response.on("data", (chunk) => {


request.on("error", error => {

1 Answer

Darryl Mah
Darryl Mah
5,485 Points


In this challenge you’ll want to concatenate the “responseBody” with “dataChunk”. Since they’re both strings you’ll can use the “+” or “+=“ to combine the two. You want to do this on the response.on function with the “dataChunk” callback

response.on(“data”, dataChunk => { responseBody = responseBody + dataChunk; });


response.on(“data”, dataChunk => { responseBody += dataChunk; });

Hope this helps!

Thank you so much!