I'm using async-retry node module. I need to return value if a condition meets other than that I want to retry.
Here is what I'm trying to do but not working:
await retry(
async () => {
const lists = await this.projectPlanService
.getProjectPlans(jwtData);
const listsWithCount = await this.populateSiteCounts(lists as ProjectPlan[]);
// if the condition meets then skip retrying, if not then retry again - how to do that?
if (lists.some(o => o.id === projectPlan.id)) {
return res.send({
success: Boolean(projectPlan.id),
projectPlanId: projectPlan.id,
lists: listsWithCount?.sort((a, b) => b.id - a.id),
});
}
return false;
},
{
retries: 5,
},
);