I am encountering an issue with my Angular + ngrx setup, and the following output is displayed in the console:
{status: true, rows: 1, data: Array(1)}
data: Array(1)
0: {id: "Q", description: "QQQQQ", is_active: true, created_at: "2021-02-05T01:24:21.594Z", updated_at: "2021-02-05T01:24:21.594Z"}
length: 1
__proto__: Array(0)
rows: 1
status: true
__proto__: Object
However, I am unable to access the properties of the object inside the array such as id. To address this, I have defined an interface like so:
export interface TipoDocumentoResult {
status: boolean;
rows: number;
data: TipoDocumento
}
The 'TipoDocumento' class is structured as follows:
export class TipoDocumento {
constructor(
public id: string,
public description: string,
public is_active: boolean,
public created_at: Date,
public updated_at: Date,
) { }
}
This is how I have configured my ngOnInit function:
this.store.pipe(
select('tipoDocumentoGetOne'),
filter(({ loading, loaded }) => loading === false && loaded === true),
).subscribe(
({ data }) => {
this._result = data
this._data = this._result?.data
console.log(this._result)
console.log(this._data[0]) // At this point, I encounter an error
}
);
Upon running this code, the following message appears:
Element implicitly has an 'any' type because expression of type '0' can't be used to index type 'TipoDocumento'. Property '0' does not exist on type 'TipoDocumento'
I apologize for any confusion in my explanation.
Warm regards