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

Ryan Yim
Ryan Yim
3,242 Points

Getting Error Message

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));

Not sure why I am getting an error here. I looked at another answer and it looked exactly the same but I'm using arrow functions.

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));