I am trying to load some data into records array inside a Promise and trying to access after the Promise is completed:
records = [];
Promise.all([
d3.dsv(",", "state-earthquakes.csv", d => records.push(d)),
d3.json("states-10m.json").then(d=>LoadMap(d))
]).then(UpdateData());
function UpdateData()
{
console.log(records);
console.log(records.length);
}
When I run this, records
is shown as empty, which is not expected (the file has data).
When I examine records from the console, I see all the records:
What explains this behavior?
I need to process the records after both method calls in the Promise are completed. How do I achieve this?