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

vincent batteast
vincent batteast
38,047 Points

Create a variable request that stores the result of the get method.

Bummer! You didn't declare the var, const or let variable.

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

1 Answer

Aaron Price
Aaron Price
5,972 Points

That doesn't work because you're assigning request to the method itself, instead of the return value of the method. Try this:

const https = require("https");

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