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 trialJoe Mackey
20,418 PointsSee the console.log(responseBody); in that callback around line 10? Fix the listener so that the
It has been a long day and the response is "Unexpected )" And I do not see that error. Cant anybody recommend a suggestion?
Thanks Joe
const https = require("https");
const request = https.get("https://teamtreehouse.com/chalkers.json", function(response) {
let responseBody = "";
});
response.on("data", function(dataChunk) {
responseBody += dataChunk; });
});
response.on("end", (function) () {
console.log(responseBody);
});
request.on("error", function(error) {
console.error(error.message);
});
3 Answers
chrisgoodell
4,541 PointsThis course is terrible
Marlene Guzman
9,231 Pointsso they want you to add "end" to the response function.
response.on("end", () => {
console.log(responseBody);
});
so your completed code will look like this.
const https = require("https");
const request = https.get("https://teamtreehouse.com/chalkers.json", response => {
let responseBody = "";
response.on("data", dataChunk => {
responseBody += dataChunk;
});
response.on("end", () => {
console.log(responseBody);
});
});
request.on("error", error => {
console.error(error.message);
});
andren
28,558 PointsI notice two syntax errors in your code:
The first one is in this line:
responseBody += dataChunk; });
The callback and function is closed on the line below so the last couple of characters "});" do not belong on that line.
The second is in this line:
response.on("end", (function) () {
The parenthesis wrapping the function keyword is invalid, they should not be there.
If you remove the unnecessary characters and the parenthesis I pointed out above then your code should work.
chrisgoodell
4,541 Pointschrisgoodell
4,541 PointsI wish Treehouse would redo this course with Guil. His courses are so clear and well put together.
Laura Sweet
2,782 PointsLaura Sweet
2,782 PointsAgreed! Very hard to follow.
L Haney
Front End Web Development Techdegree Student 10,263 PointsL Haney
Front End Web Development Techdegree Student 10,263 PointsThe explanations are good, but this course needs more practice problems. If you don't apply the concepts enough, all the information will just go in one ear and out the other.
If you're looking for extra practice, The Odin Project has a course on Node that's free.
Cody Tapp
9,667 PointsCody Tapp
9,667 PointsYeah pretty much every course with Chalkers really makes me hesitate.