Here is my for loop, It runs over 2 enums, and send both of them to the server, get's a value, and calculate the value through another for loop. Pretty sure it can be improved. here is the code:
const paths = [];
for await (let category of Object.values(CategoriesEnum)) {
for await (let format of Object.values(FormatsEnum)) {
const totalPosts = await getPagesCount(category, format);
const totalPages = Math.ceil(totalPosts.offsetPagination.total / 12);
for (let page = 1; page <= totalPages; page++) {
paths.push({ params: { category: category , format: format page: page } });
}
}
}
return paths;
My main goal is to reduce the time, although i understand that the server will get the same amount of queries so the differences won't be huge. Thanks.