i can get 'sm' in console.log result before push it, but got undefined when try to push.
chooseMenu(menu:Menuitems){
const sm = {name:menu.name,quantity:1,price:menu.product[('price')]}
console.log("item add",sm);
this.choosenMenu.push(sm);
}
'price' become undefined, please guide so i can push 'sm'.
here is data response menu:MenuItems
{
"data": {
"items": [
{
"id": 15,
"name": "Canadian Wrap",
"product": {
"price": 6.99
}
},
{
"id": 12,
"name": "Chicken Caesar Wrap",
"product": {
"price": 5.75
}
},
and result console log for 'sm'
name:"Caramel Sundae"
price:2.99
quantity:1
i have no access to do
menu.product.price
or
menu.product[0].price
how to make sure "price" not become undefined so i can push it, thank you