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

I'm not sure what the 'result' is? Is this the whole JSON string that's returned?

Do we something like what the previous exercise had done? E.g declare the new variable 'request' but make empty. Then read data and compile into a full string at the end?

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

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

});

3 Answers

Steven Parker
Steven Parker
203,693 Points

The instructions say "Create a variable request that stores the result of the get method.". The "get method" is the entire call, so this is not something you would do inside the callback argument.

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

They probabably mean:

https.get("https://teamtreehouse.com/chalkers.json", response => {
    response.on('data' result => {
        console.log(result);
    }
});

yeap, didn't read the question properly. Thanks guys