I'm missing something basic. I'm grabbing data from an api and trying to push it into an array of json objects. The api works fine and I'm getting data, but it does not seem to get pushed into the array. Also I can't seem to console log any of the data with parameters. Here is my jQuery code:
var jsonArr =[]
var jsonData = {}
$.get(apiGetList,function(r) {
$(r).each(function(i) {
$.get(api_checklist_start + r[i].id +api_checklist_end ,function(s){
$(s[0].checkItems).each(function(k){
jsonData =
{"item": [k],
"task": r[i].name,
"name": s[0].checkItems[k].name,
"state": s[0].checkItems[k].state
}
jsonArr.push(jsonData)
})
})
})
})
console.log(jsonArr)
When I view the console I see:
The array is empty, but all of the objects from the API are coming through. If I try to console.log jsonArr[0] I get undefined.
Any ideas on how to access the objects I have pulled in from the API?