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

karan Badhwar
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
karan Badhwar
Web Development Techdegree Graduate 18,135 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,330 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 seal-36
karan Badhwar
Web Development Techdegree Graduate 18,135 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,330 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."