When bringing the direct data from the bd it returns me
[object Object],[object Object]
My question is the following
this.CotizacionService.listaPartidasPorIdCliente(this.data.id).subscribe(res => {
this.listaInformacion = res
});
}
When printing the variable res
it returns me (2) [{…}, {…}]
more, however I don't know how to access each one of them up to their property as res[0].id
without it being mechanical but rather I can access each property that the array contains
A good practice is to create an interface with the data you expect to receive, it is an invaluable help because you are not blind.
Example: You have your query, which goes to your service:
in your service you are making the query to your backend:
Now you create an interface in this way in a file with this name
partidas.interfaces.ts
where you include all the fields of your responseThis is just an example, with this you already have in your query subscription to your backend all the typing of the response and it will autocomplete when you need to access any element of your response.
Now in your query and with the interface example that we created you can access it like this.
You must also initialize the variable in your component
listaInformacion
like so: