I think I'm fundamentally misunderstanding something here in Javascript.
Could someone please explain why I get SyntaxError: Unexpected identifier
when trying to call getUrlContent
from inside the forEach:
(async () => {
let sitesState = []
urlsToCheck.forEach(url => {
sitesState.push({
"url": url,
"data": await getUrlContent(url)
})
})
})();
async function getUrlContent(url) { ... }
Why does this happen (and of course, how do I write this correctly?).
Any help appreciated.
Thanks.