I'm sure this question has been asked before, but is there a way to flatten a promise in JavaScript?
For example:
let justAPromise: Promise<something> = aPromise.flatMap( a => getAnotherPromise());
Or like this:
let promiseOfPromise: Promise<Promise<something>> = aPromise.then( a => getAnotherPromise());
let justAPromise: Promise<something> = promiseOfPromise.flatten();
UPDATE:
To clarify the concept of flattening a promise. I distinguish between these two scenarios. The first is a promise of an integer, and the second is a promise of a promise of an integer:
Promise.resolve(23);
Promise.resolve("whatever").then(a => Promise.resolve(23));