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 trialTakuya Hirata
23,296 PointsgetProfiles without a parameter?
Please somebody explain why the getProfiles function can be called even though the function is called without a parameter?
1 Answer
Steven Parker
231,248 PointsThe "then" method takes up to two arguments, both callback functions. The first function is called on successful resolution, at which time it is passed the fulfillment value from the promise. So it does get a parameter when it is called (it is not being called at the spot where "then" is being used).
For more details, see the MDN page on "then".
Takuya Hirata
23,296 PointsThanks Steven,
I'm not too sure that the getProfiles function was declared like "function getProfiles(json){}", so I thought the getPfofiles function would need to take a parameter when it's called like getProfiles(something: value form pormise).
Thanks!
Steven Parker
231,248 PointsThat's exactly how it gets called. You don't specify the argument when you pass the callback to "then", but when it gets called, "then" will supply the argument.
Happy coding!
Takuya Hirata
23,296 PointsTakuya Hirata
23,296 PointsThanks Steven! Happy coding!