I'm trying to list a bunch of products and I wanted to request data on node and build the page in a static way, so The homepage would be faster.
The problem is that when I make over 80 request on GetStaticProps.
The following code with 80 items, does work
const urlList = [];
for (let i = 1; i <= 80; i++) {
const url = `myApiUrl`;
urlList.push(url);
}
const promises = urlList.map(url => axios.get(url));
const responses = await Promise.all(promises);
return responses;
The following code with 880 items, does not work (Note that is does work outside of GetStaticProps))
const urlList = [];
for (let i = 1; i <= 880; i++) {
const url = `myApiUrl`;
urlList.push(url);
}
const promises = urlList.map(url => axios.get(url));
const responses = await Promise.all(promises);
return responses;
erro on console:
Uncaught at TLSWrap.onStreamRead (internal/stream_base_commons.js:209:20)
webpage error:
Server Error
Error
This error happened while generating the page. Any console logs will be displayed in the terminal window.
TLSWrap.onStreamRead
internal/stream_base_commons.js (209:20)
Is there a way to handle large requests amount like that? I'm new to hhtp requests, is there a way for me to optimize that?