One convenient feature of Promises is you can now use async await as seen in the following example. With this pattern, an exception will be thrown if the API call was not successful and the Promise was rejected.
Another pattern is usage of the then, catch, and finally methods on the Promise object, which improves error handling. Here, the catch method is explicit and if the Promise is rejected without a catch, an unhandled promise rejection event will be sent to the global scope.
Finally, the following example demonstrates the existing usage of the callback pattern. Callbacks will continue to be supported, although new asynchronous methods may only support Promises in the future.
For more information on Google Maps Platform, visit our website.
Cloud BlogRead More