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 trialdaniwao
13,125 PointsChallenge Task: Node Basics
I'm not sure what I'm doing wrong here. I am inputting dataChunk as the argument and then concatenating it to the responseBody.
var http = require("http"); var request = http.get("http://teamtreehouse.com/chalkers.json", function(response){ var responseBody = "";
response.on("data", function(dataChunk) {
});
//Here is my code below.// response.on("", function(dataChunk){ responseBody += dataChunk; });
});
request.on("error", function(error){ console.error(error.message); });
var http = require("http");
var request = http.get("http://teamtreehouse.com/chalkers.json", function(response){
var responseBody = "";
response.on("data", function(dataChunk) {
});
response.on("", function(dataChunk){
responseBody += dataChunk;
});
});
request.on("error", function(error){
console.error(error.message);
});
1 Answer
Hugo Paz
15,622 PointsHi daniwao,
You have the correct code, just in the wrong place. You need to add that line here:
response.on("data", function(dataChunk) {
});