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 2017 Building a Command Line Application Making a GET Request with https

Leo Marco Corpuz
Leo Marco Corpuz
18,975 Points

Response function

I see in the video that the response function has no () before the arrow. Is the () optional?

1 Answer

Mischa Yartsev
Mischa Yartsev
20,562 Points

Hi, Leo Marco Corpuz !

Yes, you're right. If your Arrow function has only one argument like in this case only one argument response than you could omit the brackets.

const request = https.get(`https://teamtreehouse.com/${username}.json`, response => {
  console.log(response.statusCode)
})

Please refer to MDN docs:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

or of course Treehouse workshop for more info about Arrow functions:

https://teamtreehouse.com/library/introducing-arrow-function-syntax