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 Asynchronous Programming with JavaScript Understanding Promises Create a Promise

karan Badhwar
seal-mask
.a{fill-rule:evenodd;}techdegree
karan Badhwar
Web Development Techdegree Student 13,921 Points

Is promise is an API

I am not getting it, how promise Object is an API now, I am getting very confused with this whole API situation, what I believe API is what creates a connection between Two networks or computers, but what does it mean now by promise API? Can somebody please explain me this ?

1 Answer

Joe Elliot
Joe Elliot
5,329 Points

I found this a bit confusing as well. After my research this what I understand so far (I could be completely wrong).

You're right that the API is a way for two things to communicate more seamlessly.

"An API (Application Programming Interface) is a set of functions that allows applications to access data and interact with external software components, "

They give the example that if you made an app for an iPhone, you wouldn't need to programme how the iPhone camera works. You could just use the camera API.

So in this case, you're using the Promise API, which in itself is a set of functions that does some of the hard work of sending and receiving requests.

karan Badhwar
seal-mask
.a{fill-rule:evenodd;}techdegree
karan Badhwar
Web Development Techdegree Student 13,921 Points

HI Joe Elliot, thankyou so much for the explanation. Just to make sure, I get it, you mean to say, API works for the asynchronous work inside a program or a software as well, that means API is a mediator for every thing that runs over the Internet or network. In this case Promise is just like the XMLHTTPRequest Object that offers other methods that help us to get the connection for AJAX request, Is my understanding right?

Joe Elliot
Joe Elliot
5,329 Points

Yes Karan, I believe you're right!

This website has a really good explanation: https://www.ibm.com/cloud/learn/api "APIs sit between an application and the web server, acting as an intermediary layer that processes data transfer between systems."