Loop Through A JSON In Angular2/typescript
{   'data': [     {       'type': 'product',       'id': '138e45b2-5321-8d6c-94d0079ac1f6',       'name': 'Hendricks',       'slug': 'hendrick',       'sku': 'fcusdfckss',       'm
Solution 1:
When you are using forEach as per your sample data, the below code should work
 products.data.forEach(element => {
    let product = {
                name : element.name, 
                sku : element.sku, 
                description : element.description,
                price: element.price[0].amount
                }
    console.log(product);
});
Post a Comment for "Loop Through A JSON In Angular2/typescript"