Promise.resolve()

The Promise.resolve() static method "resolves" a given value to a Promise . If the value is a promise, that promise is returned; if the value is a thenable , Promise.resolve() will call the then() method with two callbacks it prepared; otherwise the returned promise will be fulfilled with the value.

This function flattens nested layers of promise-like objects (e.g. a promise that fulfills to a promise that fulfills to something) into a single layer — a promise that fulfills to a non-thenable value.

Try it