如果我不知道 ID,如何获取 "qty" 和 "price" 值并访问项目 [array]
how can i get the "qty" and "price" value and access in to the item [array] if i dont know the ids
I am building a shopping cart and this is for the "previous orders" page in order to show the details. I am trying to print it in an (.ejs) file. The object consists of few nested object and inside one object other properties are referred by the mongoose product id while storing the purchase details.
您可以获取 Object.keys(items)
以获取所有 ID 的列表
您可以遍历“items”对象的键并使用该键检索整个 item-object。
Object.keys(items).forEach(function(key,index) {
console.log(key);
console.log(items[key])
})
I am building a shopping cart and this is for the "previous orders" page in order to show the details. I am trying to print it in an (.ejs) file. The object consists of few nested object and inside one object other properties are referred by the mongoose product id while storing the purchase details.
您可以获取 Object.keys(items)
以获取所有 ID 的列表
您可以遍历“items”对象的键并使用该键检索整个 item-object。
Object.keys(items).forEach(function(key,index) {
console.log(key);
console.log(items[key])
})