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 trialKylie Soderblom
3,890 PointsI don't get the first "get" of module.exports.get = get;
Nope! Still lost. Listened to this snippet several times. module.exports.get = get; // "name of your api that you want accessible is the first 'get', and then set it to the get function."
I want to export a module so: module.exports Why does it have to have the word 'get' as the name of my api? Not even sure what api means here. I know what the acronym stands for but what does it mean here?
why would he choose to change the getProfile function name to get --- it just adds to the confusion. Let's say, I change the function name to userProfile then I would module.exports.get = userProfile;
but once again - why the first get?
1 Answer
Jason Arnold
22,110 PointsThat first get
is the name you are giving to your export. The second is the name of the function.
You could just as easily name it module.exports.apples = get;
and then use users.forEach(profile.apples)
in app.js
and it would work.
If you had multiple functions you wanted to export out of profile.js
and wanted to give each their own name, you could.
Honestly, I'm not sure why they renamed the function or why there are using 'get' for both the function's new name and the export. It just adds to the confusion.
Also, this question is on the wrong module (this one is for handling error codes), which is probably why it hasn't been answered before now. I think a lot of other students had similar questions: https://teamtreehouse.com/community/video:78042