JavaScript Node.js Basics Handling Errors in Node Handling Errors in Node

Damian McCarthy
Damian McCarthy
3,656 Points

You didn't call `console.error` in the error callback.

I am not sure why I am getting this error because it is there.

app.js
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}'));

2 Answers

Steven Parker
Steven Parker
159,270 Points

You're attempting to use string interpolation, but your string is enclosed with apostrophes ("single quotes"). String interpolation is only performed on strings enclosed with accents ("back ticks").

But the challenge isn't expecting that anyway. And since error.message is a string, you can use it directly as the argument to the console function.

Damian McCarthy
Damian McCarthy
3,656 Points

I really don't get it then. What am I supposed to be doing if not that?

Steven Parker
Steven Parker
159,270 Points

What I mean by "use it directly as the argument" would look like this :point_right: console.error(error.message)