I am trying to create a wrapper function that returns a Promise object which will resolve after an inner Promise resolves. Basically, something like this:
function wrapper() {
return new Promise((resolve, reject) => {
MyApi.asyncCall()
.then(data => {
// do this first, then resolve outer promise
resolve();
})
.catch(e => {
reject();
});
});
}
The reason I need to do this is I have an interface that accepts a promise argument, then triggers an action once that promise resolves. I need to make an async call, then do something with the response, then trigger the interface.
Edit Explanation of purpose: I need to perform actions with the response of the inner promise BEFORE resolving the outer promise. The interface accepts an unresolved promise object, and then mounts a component when it is resolved. If I pass the inner promise it will mount before the actions on the data response are performed.