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

declaration error

error during declaration of variable

app.js
const https = require("https");
var request = "";

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

2 Answers

Romain Gaget
Romain Gaget
24,449 Points

Hi, you just need to declare your var request before https.get...

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

thanks i solved it