I am reading a list that has the following structure:
export interface ISaleEntity {
id: number;
dateCreated: Date,
amount:number,
type:string,
description:string
}
My api is returning the following data:
payments: Array(2) 0: {Id: 1, Type: "DEBIT", Description: "Sale 1", Amount: 5000, DateCreated: "06/18/2018 00:00:00"} 1: {Id: 2, Type: "CREDIT", Description: "Sale1", Amount: 4200, DateCreated: "06/20/2018 00:00:00"}
Since I am using transcript, I do
const payments: ISaleEntity [] = response.data.payments;
private renderData(payments: ISaleEntity[]) {
return (
<div>
{payments.length}
{payments.forEach(element =>
// tslint:disable-next-line:no-console
console.log("element" + element)
// <span>{element.description}</span>
)}
</div>
);
}
In console, element is [object Object].
How can I read the loop through JSON object properties?