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

Arthur Dedela
Arthur Dedela
6,730 Points

Create a variable request

I tried my best, but it always says: "You didn't declare the var, const or let variable correctly." Help me please.

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

1 Answer

andren
andren
28,474 Points

You seem to have misunderstood the task a bit. They want you to store the https.get request itself to a variable. Not the content of the response.

Like this:

const https = require("https");

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