I have code that is making an HTTP request in a forEach
iteration. The problem is, all of the HTTP requests are firing off at once.
const main = async () => {
items.forEach(async (i: Item) => {
const response = await fetch(/* code and stuff */)
});
}
main()
I am flooding the server with requests in this particular case as all items are subsequently firing off.
Is there a way to make the fetch synchronous in this case, so that only one is being sent to the URL behind fetch()
at a time?