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 React Authentication Implementing Basic Authentication Set up Basic Authentication

Damian Szymanski
Damian Szymanski
11,843 Points

Is there any documentation for the api() {} method used here?

Hi! I was wondering if there was any documentation for the api() {} method that's used here as I would like to understand it further.


2 Answers

Motoki Higa
Motoki Higa
14,111 Points

I know it's late, but I had a some question in the beginning of the course, but api() is essentially a custom helper method, so there is no official document about the function/method. You can name the function whatever, and you can customise the function however you like to suite for your purpose!

As Motoki Higa explained, It also took me a little while to get around it, then I realized that the whole Data class is there to simplify things, api() is just a customized method made by whoever wrote the course to make things easier and avoid having to send fetch requests over and over again with different URLs and parameters.