I'm attempting to extract the values of objects in an array using a nested for loop. I am receiving JSON data as shown below and have written the following TypeScript code to achieve this. However, I am unable to successfully bind the values to the template. Please see my code below:
Here is the TypeScript code snippet:
let totalData = results['data'];
for (var i=0; i<totalData.length; i++)
for (var task in totalData[i]) {
console.log("Task: "+task);
console.log("totalTests: "+task['totalTestCompleted']);
console.log("totalOpenIssues: "+totalData[i][task].totalOpenIssues);
}
The JSON data received from the REST API is as follows:
[
// JSON data snippet here
]
I am aiming to access the keys and values of the task object as shown below:
task.totalTests
task.totalOpenIssues
When attempting to extract the JSON array object values, I encounter the following error:
ERROR TypeError: Cannot read property 'totalTestCompleted' of null
I have tried to bind these values to the template but I am facing difficulties in extracting the array of JSON object values. Can someone provide guidance on this matter?
Thank you.