Using cors anywhere, I am fetching a site which needs to load in a module of information - such as avaliable domain names. However, fetch works by waiting until the website loads before returning a fulfilled promise, although this doesn't mean that the site can load more data even after the site has finished loading.
Simply, I'm trying to fetch a domain search website and see what domains are available, when the promise returns (with the HTML body contents), I strip only the necessary data such as if a domain is available and display it in my site.
Therefore, is it possible to establish a connection to a website, then afterward, wait an additional 10 more seconds before returning the new content that the site I am fetching to load in?
Here is my current code
async function accessURL(website) {
let response = await fetch('https://corsanywhereexample.com/'+website);
return await response.text();
}
await accessURL('www.example.com/content').then(text => document.body.innerHTML = text);
Based on the code above, using my own cors anywhere nodejs server, it successfully fetches the website HTML, where I can display on my site, however, the site is incomplete, as it was still loading in data from the server (which wasn't returned inside the fetch)
Is there potentially something like this which could wait 10 seconds before returning any new information in the site?
async function accessURL(website) {
let response = await fetch('https://corsanywhereexample.com/'+website);
return new Promise(resolve => setTimeout(() => { await response.text() }, 10000))
}
await accessURL('www.example.com/content').then(text => document.body.innerHTML = text);