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 trialGraeme Oxley
8,931 PointsQuiz issue: Can't see what I am doing wrong
I have looked back to the previous video several times and my code is exactly as he did it, though I keep getting an error saying that I did not call the 'console.error', though I clearly did.
I am at a loss for what I am doing wrong, and the video has no more clues to give.
const https = require("https");
const request = https.get("https://teamtreehouse.com/chalkers.json", response => {
console.log(response.statusCode);
});
request.on('error', error => console.error('Problem with request: ${error.message}'));
3 Answers
Adam Pengh
29,881 PointsI got this to work
const https = require("https");
const request = https.get("https://teamtreehouse.com/chalkers.json", response => {
console.log(response.statusCode);
});
request.on('error', (error) => {
console.error(error.message);
});
Romain Gaget
24,449 Pointsyou've used single quote in your error message where you should use back-tick (`) instead in order to use template literal syntax
request.on('error', error => console.error(
Problem with request: ${error.message}`));
Graeme Oxley
8,931 PointsThank you for the alternative answer. Obviously at this stage I haven't even heard of the use of the back-tick for any functional purpose, and upon looking back I see that I did confuse the video's use of the back-tick for a single quotation.
It would have been helpful if Chalkers had mentioned the back-tick use since I don't imagine it is something that a novice would be used to seeing.
Steven Parker
231,261 PointsRomain is correct about needing accents ("back-ticks") to define template literals, but that's not what you need here to pass the challenge.
When the instructions say "print out the error message", they literally mean just the message property of the error object itself. You won't need any additional strings this time.
Graeme Oxley
8,931 PointsThank you for the help, though admittedly your 2nd paragraph didn't help me to understand the problem since it was simply an explanation of the answer which I didn't really understand until I saw the code that Adam Pengh posted (easier to learn from code than text, for me at least).
Steven Parker
231,261 PointsI was afraid I was being a bit too explicit. When I said "the message property of the error object itself" with "no additional strings" I expected it would translate directly into "error.message", which was what you used to pass the challenge.
Graeme Oxley
8,931 PointsGraeme Oxley
8,931 PointsChoosing this one because it seemed to be closer to what I was expected to do from the beginning. Part of me is simply confused because I am not sure how I was expected to arrive at that answer to begin with. I only got as far as I did after a good amount of trial and error with no feedback from the quiz to help me understand what is wrong.
Thanks for the help.