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 trialangelicaestrada
9,863 PointsNeed 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. Please...help...
const https = require("https");
const request = https.get("https://teamtreehouse.com/chalkers.json", response => {
let responseBody = "";
response.on("data", dataChunk => {
});
response.on("data", (chunk) => {
console.log(chunk.responseBody);
});
});
request.on("error", error => {
console.error(error.message);
});
1 Answer
Darryl Mah
5,492 PointsAloha,
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; });
Or
response.on(“data”, dataChunk => { responseBody += dataChunk; });
Hope this helps!
angelicaestrada
9,863 Pointsangelicaestrada
9,863 PointsThank you so much!