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 trial

JavaScript Node.js Basics (2014) Building a Command Line Application Handling Errors in Node

Gi Devs
Gi Devs
12,171 Points

you didnt call the console.error . . . but I did

I've been having problems with this challenge saying it's not passing when I think it should be, right now it's telling me the I haven't called the console.error method in the request error call back when I have. I've tried all sorts of things to try to make it pass but it just wont work.

here is my code

app.js
var http = require("http");
var request = http.get("http://teamtreehouse.com/chalkers.json", function(response){
  console.log(response.statusCode);
});

request.on('error', function(error){
  var msg = error.message;
  console.error(msg);
});

2 Answers

jason chan
jason chan
31,009 Points
var http = require("http");

var request = http.get("http://teamtreehouse.com/chalkers.json", function(response){
  console.log(response.statusCode);
});

request.on('error', function(error){
 console.error(error.message);
});
Gi Devs
Gi Devs
12,171 Points

I did the challenge again and it worked fine for me. btw I did original have it like that I moved it around to try to fix the error. I still don't understand what was wrong but I managed to pass the challene

jason chan
jason chan
31,009 Points

Probably it was cache error. I guess second time is a charm. ;)

Gi Devs
Gi Devs
12,171 Points

I guess so. I did check your code and it worked so I'll give it a best answer