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 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!