The API i'm using to get JSON data only lets you put in a single date, and they don't have any methods for getting multiple dates. Therefor, I decided to create a for
loop to loop through some dates, to pick up all the json data I need. The problem is, the loop does not wait for the json file to return the data, so even though I get some of the data, I don't get all of the data. What is worse, is some dates are slow to come back, so they don't even get pushed into the array in the right order. It just pushs them in, in a somewhat random fasion. How can I tell the loop to "wait" until I get the data, until looping again?
jsonDataArray = [];
for (var k = 10; k < 20; k++){
var num = k;
var n = num.toString();
var mydate = "2017-02-"+n;
d3.json("http://api.fixer.io/"+mydate, function (jsonData) {
jsonDataArray.push(jsonData);
}
)}