I wrote a for loop that iterates over 2 enums, sending them both to the server, receiving a value in return, and then calculating another value using a nested for loop. I believe there is room for improvement in this code snippet:
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 primary objective is to reduce execution time, although I acknowledge that the server will still receive the same number of queries so any improvements might be marginal at best. Thank you for your consideration.