How can I keep fetching the webpage while it didn't get response being in a loop?
for (node of NodeList) {
const url = node.getAttribute('href')
const res = await fetch(url) //Code below won't execute if no response
const html = await response.text()
const scraper = new DOMParser()
const doc = scraper.parseFromString(text, 'text/html')
alert('successfully parsed')
}
So as it works in a loop and sends very many requests at a time, even a small and short issue with network can spoil the whole process, what can I do?
I never loop AJAX, it can overwhelm the server and the browser (if in a browser) will not have time to update the interface.
I would try something like this
the asynchronicity is solved by only calling the function again when success or error