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 (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,386 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,386 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,386 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,413 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.