Get the API response and store the data in to an array

Discussão em 'Angular' iniciado por trx, Fevereiro 26, 2025.

  1. trx

    trx Guest

    I am trying to call an API from my Angular Application and get the data back use the data in to my front end. I get the response back but I am not sure how to get a specific field from the JSON and store them in to an array

    dataList;
    apiUrl = 'GetDatafromSys?prj=123;

    constructor(service: DataService) {
    service.get<any>(this.apiUrl).subscribe(x => {this.dataList = (JSON.stringify(x)); });
    }


    I get the dataList back as JSON like

    [
    {
    "Name": "Jack",
    "EmpNo":"123"
    },
    {
    "Name": "Joe",
    "EmpNo":"456"
    }
    ]


    I am not sure how to get the Name from the JSOn and store in a array so I can use it as a data source for a dropdown

    <dx-select-box [dataSource]=""

    Continue reading...

Compartilhe esta Página