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 What is Asynchronous Programming? The JavaScript Call Stack

karan Badhwar
.a{fill-rule:evenodd;}techdegree seal-36
karan Badhwar
Web Development Techdegree Graduate 18,111 Points


What is an API, is Async development is all about Web API's ?

On google as per the API's definition, it is some sort of messenger that takes the request and returns back with the response, but how it is a Web API container that holds the Async code? and how does the browser know that this code will make block the Script, other than pre-defined methods like setInterval or setTimeout, how about some code that requires the wait time, how the JS engine gets that it will block the script?

One more thing how do we pull the API from another site, as we can have different API's how do we get to know that the API is to retrieve data? what I understood is that API creates the connections, so how does a URL pass on the all the info we required, how does it know what we want?

1 Answer

Steven Parker
Steven Parker
220,425 Points

It's better to give the community at least 24 hours to answer a question before tagging anyone in particular. Also, questions like this will sometimes be answered in the course if you continue a few steps further.

Whoever designs the API should provide documentation for others to use it. All API's are a bit different, but a typical way to pass info to an API is through the query string appended to the URL starting with a question mark.

Timers are not the most typical way to implement async access to an API. A much more common way would be to use a mechanism that generates an event or invokes a callback when data is received. This is the case with the AJAX and Fetch operations that this course talks about.