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 React Authentication (2019) 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.

Thanks!

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.