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 trialIan Blair
7,411 PointsUsing the proper callback from the video example still gives me a Bummer! Try again.
Here is the question. "On a new line use the on method to listen for the error event. Pass in a callback function with one parameter of error."
I can't figure out what's wrong with my code because this is straight from the tutorial video.
Thanks for the help!
var http = require("http");
http.get("http://teamtreehouse.com/chalkers.json", function(response){
console.log(response.statusCode);
});
var request = http.get
request.on('error', function(error){
});
3 Answers
Jeffrey Smith
Courses Plus Student 15,508 PointsI think you're handling the error correctly. I think the issue is from the previous step. There was already an http.get that was given. Try setting your var request equal to that.
var request = http.get("http://teamtreehouse.com/chalkers.json", function(response){ console.log(response.statusCode); });
Ian Blair
7,411 PointsYes that totally fixed it! I guess it shouldn't have let me pass the first test.
Matt Homer
11,936 Pointsor you can shorten with an arrow: request.on('error', error => {});
Amber Joyner
10,782 PointsAmber Joyner
10,782 PointsHaving the same issue here as well.