0

am trying to log all the "product_id" of id 77 and id 80 of the 'user' array, i tried this using map function to log the values but failed to log. Can't figure out the error. need to access "id 266" of image object list

[
    {
        "id": 77,
        "title": "Fog Linen Chambray Towel - Beige Stripe",
        "variants": [
            {
                "id": 1,
                "product_id": 77,
                "title": "XS / Silver",
                "price": "49"
            },
            {
                "id": 2,
                "product_id": 77,
                "title": "S / Silver",
                "price": "49"
            },
            {
                "id": 3,
                "product_id": 77,
                "title": "M / Silver",
                "price": "49"
            }
        ],
        "image": {
            "id": 266,
            "product_id": 77,
            "src": "https://cdn11.bigcommerce.com/s-p1xcugzp89/products/77/images/266/foglinenbeigestripetowel1b.1647248662.386.513.jpg?c=1"
        }
    },
    {
        "id": 80,
        "title": "Orbit Terrarium - Large",
        "variants": [
            {
                "id": 64,
                "product_id": 80,
                "title": "Default Title",
                "price": "109"
            }
        ],
        "image": {
            "id": 272,
            "product_id": 80,
            "src": "https://cdn11.bigcommerce.com/s-p1xcugzp89/products/80/images/272/roundterrariumlarge.1647248662.386.513.jpg?c=1"
        }
    }
]
 user.map(({variants,title},id)=>
        {
            return (<div key={id}><span>{variants.title}</span></div>)
        })

0 Answers0