I have this code:
_getSupport()
.then((data) => {
_getSupport(data[0])
.then(() => _getSupport(data[1])
})
.catch(e => {
console.log(e);
});
_getSupport
return a Promise
.
My goal is to call again _getSupport
on values returned the first time.
So I tought:
_getSupport()
.then((data) => {
let a = [];
data.forEach(element => {
a[element] = _getSupport(element)
});
Promise.all(a).then().catch(e => {
});
})
.catch( e => {console.log(e)})
But this does not work, the code always goes to the last catch.
UPDATE
The getSupport()
is of this form
function _getSupport(param = {}) {
return new Promise((resolve, reject) => {
remoteClient.sendRequest(request, function (data) {
resolve(data);
});
});
}