I'm new to TS and I'm not sure if i understand it correctly. From my BackEnd I get data, that's looking like this:
{
"A": [
{
"fieldA": 0,
"fieldB": "A",
"fieldC": 123,
"fieldD": 0,
},
{
"fieldA": 0,
"fieldB": "A",
"fieldC": 111,
"fieldD": 0,
},
{
"fieldA": 0,
"fieldB": "A",
"fieldC": 99,
"fieldD": 0,
},
{
"fieldA": 0,
"fieldB": "A",
"fieldC": 24,
"fieldD": 0,
},
{
"fieldA": 0,
"fieldB": "A",
"fieldC": 21,
"fieldD": 0,
},
{
"fieldA": 0,
"fieldB": "A",
"fieldC": 11,
"fieldD": 0,
},
{
"fieldA": 0,
"fieldB": "A",
"fieldC": 75,
"fieldD": 0,
},
{
"fieldA": 0,
"fieldB": "A",
"fieldC": 76,
"fieldD": 0,
},
{
"fieldA": 0,
"fieldB": "A",
"fieldC": 13,
"fieldD": 0,
}
],
And my TypeScript class for this response is looking like this:
export class someDataFromBackend{
public data: {
[key: string]: {
fieldA: string;
fieldB: number;
fieldC: string;
fieldD: number;
};
}[];
constructor(data: any) {
this.data = data;
}
}
My problem is that I don't really know how can I call to any of this elements right now. I'd like for example create new Array containing values from all fieldC. Or even something that simple like to print fieldC from 2nd array inside "A" (the one that has value 111).
Even when I try to console.log(someDataFB.data) but it shows that it's undefined.