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 trialAndrey Ryazanov
7,886 Pointsmaking a get request. node.js challenge
Cannot pass through Task 2 of making a get request node.js challenge. Pls help.
Task: "On a new line, call the get method on the http object you created. Pass in the string of http://teamtreehouse.com/chalkers.json."
My code:
var http = require("http");
http.get("http://teamtreehouse.com/" + "chalkers" + ".json");
6 Answers
Antonio De Rose
20,885 Pointsthis did work for me eventually.
const https = require('https');
https.get("https://teamtreehouse.com/chalkers.json", response => { });
Ryan Zimmerman
3,854 PointsYeah I haven't done this one yet. But when you make a get request depending on if it is http or https can really affect the api you are trying to grab. A lot of times you will return a header and have to build an if statement to see which one you get and go from there.
Seth Kroger
56,414 PointsI think the challenge is looking for you to pass in the whole string, since that is what it's asking for. Using concatenation shouldn't matter because you'll end up with the same string, but with the checking software it does. I've checked and just this works, but breaking up the URL doesn't.
http = require('http');
http.get("http://teamtreehouse.com/chalkers.json");
Eric Green
6,521 PointsThe https passed for me. I agree with Ryan. The when you make a get request depending on if it is http or https can really affect the api you are trying to grab!
https.get('https://teamtreehouse.com/chalkers.json');
Thorbjørn Bak Jensen
15,043 Pointsor simply const https = require("https"); https.get("https://teamtreehouse.com/chalkers.json");
Damjan Bozinovski
9,916 PointsThe teacher is really bad and the challenge isn't properly adjusted. You need to add steps 2 and 3 together in order to pass step 2, and then just press check work again and you pass step 3.
Andrey Ryazanov
7,886 PointsAndrey Ryazanov
7,886 PointsWow. I passed it. The weird solution: