Return a resolved promise with Promise.resolve

2019-11-24

When I wanted to return a promise which is already resolved, I used to do this:

return new Promise(resolve => resolve(value))

But it can be done in a simpler way like this:

return Promise.resolve(value)

More about Promise.resolve: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve