In my current coding situation, I am facing an issue where the HTTP requests are being made simultaneously within a forEach loop. This leads to all the requests firing off at once.
const main = async () => {
items.forEach(async (i: Item) => {
const response = await fetch(/* code and stuff */)
});
}
main()
The multiple requests sent to the server concurrently are causing it to get flooded with requests. Is there a way to modify the code so that the fetch calls are executed synchronously, sending only one request at a time to the URL defined in the fetch()
function?