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

How to pass in an anonymous function?

Now, in the http.get() call pass in an anonymous function as a callback with the parameter response. This function is the second parameter in the get call.

I received this message. Bummer! missing ) after argument list

app.js
var http = require ("http");
http.get("http://teamtreehouse.com/chalkers.json" function(response) );

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi Jason! You're very close here. Because we're now passing in two things to the .get method we now need to separate those two things with a comma. Also, a function requires open and closed curly braces. Take a look:

var http = require('http');
http.get("http://teamtreehouse.com/chalkers.json", function(response){
});

Here we're sending in the URL and an anonymous function. Because these are arguments, they need to be separated by a comma. The response is sent in to the anonymous function, and that part you had correct. But we also still need the open and closed curly braces.

Hope this helps! :sparkles:

Thanks, Jennifer. I understand now. I just didn't see it the code challenge.

Is there a way to once an answer is marked best, to go back and review or saved it. In order to recall it, for a later code challenge, if needed?

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Not that I'm aware of. I generally just keep a list of links in a text file with notes describing what the problem/answer was about :smiley:

Thanks for that bit of information