Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Node.js Basics (2014) Building a Command Line Application Making a GET Request with http

mark anderson
PLUS
mark anderson
Courses Plus Student 1,279 Points

Can't figure out the question or answer...

I've tried to take 'my' code out and put in the template code... nothing seems to work. Any ideas?

app.js
//Problem: We need a simple way to look at a user's badge count and JavaScript points
//Solution: Use node.js to connect to TreeHouse API to get profile information to print out

var http = require("http");
//var username = "markanderson6";
var username = "chalkers";

function printMessage(username, badgeCount, points) {
  var message = username + " has " + badgeCount + " total badge(s) and " + points + " points in JavaScript"; 
  console.log(message);
}

//Connect to the API URL ("http://teamtreehouse.com/username.json")
//var request = http.get("http://teamtreehouse.com/" + username + ".json", function(response){
var request = http.get("http://www.msn.com", function(response){

  console.log(response.statusCode);
//Read the data
//Parse the data
//Print the data

});
Umesh Ravji
Umesh Ravji
42,362 Points

Hi Mark, which challenge are you on and which step is the problem? I cannot seem to match your template code to the challenge you have linked.

mark anderson
mark anderson
Courses Plus Student 1,279 Points

Node.js basics... lesson 1/4 "Require Node.js' http module and assign it to the variable http."

Umesh Ravji
Umesh Ravji
42,362 Points
var http = require('http');

Is That what you are looking for, is that the problem you had?

mark anderson
mark anderson
Courses Plus Student 1,279 Points

I just switched it to HTTPS and it worked !! ?? Why?????

Umesh Ravji
Umesh Ravji
42,362 Points

Mine accepts http and won't accept https, I'm not sure why yours would be the other way around :)

1 Answer

Seth Kroger
Seth Kroger
56,405 Points

This challenge will go better is you don't cut-and-paste what you did in Workspaces for the video and just type in the answers for each step as you go. In particular it's asking you get a specific URL.