After receiving data from the back-end, I handle it within a function:
getAgentSuggestionById(agentId) {
this._agentsService.getAgentSuggestionById(agentId).subscribe(result =>{
this.agent = result.items.map(e => {let obj = {name: e.name, id: e.id};
return obj;
});
debugger;
this.filteredAgents = [...result.items.map(e => {let obj = {name: e.name, id: e.id};
return obj;
})];
});
}
To transform this.agent
into an object with properties {name: e.name, id: e.id}
.
The result will always contain only one value.
Currently, it creates an array. What steps can be taken to create an object instead?