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 Handling Errors in Node Organizing Your Code with require

I don't understand why we exported only the get function

Hello, as I was watching this video the teacher made a module with most of the code inside it. I don't understand why we exported only on part of the module. Why? the code needs the whole module to work.. Somewhere I am confused. It would be great if someone could explain it to me.

Thanks, Stavros

1 Answer

Hi Stavros,

get is the only function exported because it's the only function you'd actually call in the main app. Meaning, all other functions in profile.js are used by the get function so they aren't called by the main app directly. When get is called, it has access to the other functions in profile.js so it works correctly.

Hope that helps!

Great answer you made me understand it, I thought that something like that was happening under the hood but I wanted to somewhat sure. Anyways great answer thank you very much!