var boardIdGlobal =[boardid1,boardid2];
var boardIdGlobalTemp, urlChecklistsGlobal, urlListsGlobal;
contactStatusGlobalArray = [];
function checklistStatus(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
var checklist = JSON.parse(xmlhttp.responseText);
for(i=0;i<checklist.length;i++){
for(t=0;t<checklist[i].cards.length;t++){
for(x=0;x<checklist[i].checkItems.length;x++){
if(checklist[i].checkItems[x].name.search("Contact")===0){
contactStatusGlobalArray.push(["unknown",checklist[i].cards[t].idList,checklist[i].checkItems[x].name,checklist[i].checkItems[x].state]);
}
}
}
};
};
};
xmlhttp.open("GET", urlChecklistsGlobal, true);
xmlhttp.send();
console.log(contactStatusGlobalArray);
}
function init(){
for(i=0;i<boardIdGlobal.length;i++){
boardIdGlobalTemp = boardIdGlobal[i];
urlChecklistsGlobal = "https://api.trello.com/1/boards/" + boardIdGlobalTemp + "/checklists?cards=open&card_fields=idList&key=[key]&token=[token]"
urlListsGlobal = "https://api.trello.com/1/boards/" + boardIdGlobalTemp + "/lists?key=[key]&token=[token]"
checklistStatus();
}
};
window.onload = init;
I'm using the Trello API to find the checklist status, the checklist item name, and the list id. I'm trying to push each instance of the data to a global array, to get Array [Array1, Array[8]...] etc. The console for this code logs:
Click to view image of how the .push method worked
I need to be able to loop through the global array again, but after I use .push, and try to get the length of my global array, I get a length of 0. I tried pushing objects with the same result: it looks like the .push works but that it's pushing to the same index.
How do I fix this so I get an Array of arrays (or an array of objects) that I can loop through again? I am very much a beginner so feedback is appreciated.