I'm not too familiar with JavaScript/TypeScript and I have a question about how this code snippet works:
onGet() {
this.serverService.getServers()
.subscribe(
(servers: any[]) => this.servers = servers, // an array of anything (or an array of server)
(error) => console.log(error)
);
}
As far as I understand, the onGet() method is calling the getServers() method which returns an **Observable, and then it subscribes to this returned Observable object.
My understanding of Observables is that they represent a stream of data where you can perform actions based on events. However, I'm uncertain about the specific functionality of this part of the code:
(servers: any[]) => this.servers = servers, // an array of anything (or an array of server)
(error) => console.log(error)
Could someone explain how this part works?