I have looked through the other stackoverflow answers and cannot seem to find an answer to this.
Effectively I am writing a module that verifies some data and then if there is no error passes it off to a third party api.
My issue is that if the Promise.all rejects, then my initial calling promise is still moving to next.
------my main app---------
const data = [1,0,1]
api.sendData(data)
.then( () => {
*ALWAYS HITTING THIS*
})
.catch(err => console.log(err))
---------the api---------
return await a.test(data).then(rd => {
return rd
})
.catch(ed => {
return ed
});
-----a.test function--------
let request = data.map((i) => {
return new Promise((resolve, reject) => {
if(i < 1) {
reject('value to low')
}
resolve(i);
});
});
return await Promise.all(data)
});
Could anyone tell me why my catch is not being hit in my main app? The above code is pseudo, but describes the problem.