Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Node.js Basics 2017 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
231,269 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);
});

that makes more sense

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