Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48980

Copy some specific data from API array to local array

$
0
0

I want to loop based on API array length and add or (PUSH) only {{id}}, {{qty}} from it to the local array.

API array from server

m_id: "9a915"
m_name: "test"
material: Array(2)
2:[
    {
        "id": "9528278c-4105-4c00-aff3-2d04fc57b797",
        "material_id": "92e0befb-8f75-4499-93ca-f86fa3c11df8",
        "name": "Молоток",
        "qty": "шт",
        "requested": 13,
    },
   {
        "id": "9528278c-4105-4c00-aff3-2d04fc57b797",
        "material_id": "92e0befb-8f75-4499-93ca-f86fa3c11df8",
        "name": "Молоток",
        "qty": "шт",
        "requested": 13,
    }
]

My .ts code

this.http.get( 'https://xxx.yyy.zzz/api/, options )
      .subscribe((res: any) => {
        console.log('Succeess!', res);
        this.data = res;
        loading.dismiss();
        for(var i = 0; i < res.material.lenght; i++){
          this.list.push({ id: res.material.item[i].id, qty: res.material.item[i].qty});
        }
        console.log("ITEM",this.list);
      });

But my local array(this.list) show empty in the log.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48980

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>