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 trialEliot Ostling
9,599 PointsHaven't added dataChunk to responseBody
var http = require("http"); var request = http.get("http://teamtreehouse.com/chalkers.json", function(response){ var responseBody = ""; <------
response.on("data", function(dataChunk) {
body += chunk;
});
response.on("", function(dataChunk){
console.log(responseBody);
});
});
request.on("error", function(error){ console.error(error.message); });
However if I add dataChunk to var responseBody it gives me the same error. These errors are throwing me through a loop!
var http = require("http");
var request = http.get("http://teamtreehouse.com/chalkers.json", function(response){
var responseBody = "";
response.on("data", function(dataChunk) {
body += chunk;
});
response.on("", function(dataChunk){
console.log(responseBody);
});
});
request.on("error", function(error){
console.error(error.message);
});
3 Answers
Eliot Ostling
9,599 PointsThank you, but after I modified it to https, the error it gives me, it tells me to put it back to http.
Eliot Ostling
9,599 PointsI literally answered my own question. Thank you good sir for your help!
Thomas Nilsen
14,957 PointsTry using the HTTPS protocol instead:
var https = require("https");
var request = https.get("https://teamtreehouse.com/chalkers.json", function(response){
var responseBody = "";
response.on("data", function(dataChunk) {
responseBody += dataChunk;
});
response.on("end", function(){
console.log(responseBody);
});
});
request.on("error", function(error){
console.error(error.message);
});