I'm trying to perform a few tasks in a function (fetch a web-page, and perform some calculations and such), however my list of websites to visit is in an key-value paired object.
I need to find some async/await compatible alternate to forEach
which will work on Object.keys()
.
Since Object.keys(sites).forEach(function(key, index) { ... }
doesn't seem to allow async calls within it, what's the best alternative?
The loop essentially fetches multiple sites, validates the JSON data, and adds it to a an array if valid.
It then later loops over the new array via a standard for and compares the results, before returning either boolean true
or false
.