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 trialPaul Je
4,435 PointsNot sure how to declare the request variable correctly
The syntax for js I'm not sure as I've only been focused on iOS and now am wondering if this would be a significant obstacle - I'd have to learn Javascript or at least Java in order to have no trouble with these, correct? I'd still like to learn how to go through all the objectives in this code challenge however - I'm the persistent type haha. Thanks in advance!!
var http = require("http");
http.get("http://teamtreehouse.com/chalkers.json", function(response){
console.log(response.statusCode);
});
var request = http.get("http://teamtreehouse.com/chalkers.json", function(response)
1 Answer
Thomas Nilsen
14,957 PointsYou're not very far off. It should look like this:
var http = require("http");
var request = http.get("http://teamtreehouse.com/chalkers.json", function(response){
console.log(response.statusCode);
});
request.on('error', function(error){
console.error(error.message);
});