ECMAScript Cookbook
上QQ阅读APP看书,第一时间看更新

Resolving Promise results

In the previous recipe, we saw how to use promises to execute asynchronous code. However, this code is pretty basic. It just logs a message and then calls resolve. Often, we want to use asynchronous code to perform some long-running operation, then return that value.

This recipe demonstrates how to use resolve in order to return the result of a long-running operation.