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 trialMatt Roberts
5,173 PointsI'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?
const https = require("https");
https.get("https://teamtreehouse.com/chalkers.json", response => {
console.log(response.statusCode);
let request = response.statusCode;
});
3 Answers
Steven Parker
231,261 PointsThe 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
11,835 PointsThey probabably mean:
https.get("https://teamtreehouse.com/chalkers.json", response => {
response.on('data' result => {
console.log(result);
}
});
Matt Roberts
5,173 Pointsyeap, didn't read the question properly. Thanks guys
Zimri Leijen
11,835 PointsZimri Leijen
11,835 Pointsthat makes more sense