I have an array of category ids in order, I have to make a map and fetch the items from these categories and in the end keep the original order of the array
what I've been doing:
const info = []
Promise.all(categoryItem.next_steps.map((next_step) => {
return categoryItemSvcV2.getAllItensNoOrderByCategoryId(next_step.category, idpage)
.then((result) => {
info.push(result)
})
})).then(() => {
res.json({ success: true, info })
})
the categoryItem.next_steps is the array of categoryIds on order, however each time I call this function it displays in an order