I'm currently juggling a hectic schedule and just starting to dig into callback functions. I'm facing an issue with parsing a JSON payload received from a webapp, specifically with handling an array of objects. In my script, I seem to only be retrieving the value of the last index in the array. Below is the code snippet along with the console output for reference. Any guidance on where I might be going wrong would be greatly appreciated.
var case1 = payload.Case;
var i=0;
for(i=0;i<case1.length;i++)
{
var c1 = case1[i];
c1.retrieveAttributes(function(){
console.log(i+ " i");
console.dir(c1.attributes);
});
}
The value of 'i' in the console always prints as 6.