When Ajax started appearing, it was commonly used with callbacks, which themselves could have callbacks of their own, with more callbacks within, which eventually led to coining the term callback hell. As a way out of that impractical programming style, two other styles of working with services and asynchronous calls appeared: promises and async/await—though in truth, the latter also use promises!
Doing async calls compactly
Getting started
Let's see both styles by using a simple example. This book was written in three different cities: Pune, India; London, England; and Montevideo, Uruguay, so let's do some work related to those cities. We will write code that will get weather information for those cities...