I have the below piece of code which hits a url for each user id in loop.
var requests = [];
for (let i = 0; i < userids.length; i++) {
requests.push(this.getUserData(authToken, userid[i]));
}
const userdetails=await (Promise as any).allSettled(requests);
The code fails for some requests and returns error for some requests. But when the same code is implememnted using sequential processing it works and returns correct data. Below is the code for the same
var requests:any=[]
for (let i = 0; i < userids.length; i++) {
requests.push(await this.getUserData(authToken, userid[i]));
}
How shall I fix it?