I am struggling with calling an API in my Angular application and extracting specific data from the JSON response to populate an array. Although I am able to retrieve the response, I am having trouble isolating a particular field and storing it in an array.
dataList;
apiUrl = 'GetDatafromSys?prj=123';
constructor(service: DataService) {
service.get<any>(this.apiUrl).subscribe(x => {this.dataList = (JSON.stringify(x)); });
}
The dataList
returns JSON data like this:
[
{
"Name": "Jack",
"EmpNo":"123"
},
{
"Name": "Joe",
"EmpNo":"456"
}
]
I am unsure how to extract the Name
field from the JSON and store it in an array so that I can utilize it as a data source for a dropdown menu.
<dx-select-box [dataSource]=""