router.delete('/shopping-cart/:id',(req,res) => {
let cart = new Cart(req.session.cart);
console.log(req.params.id);
console.log(cart.generateArray());
});
console.log(cart.generateArray())输出跟随结果
[{
item:
{
_id: '5c863cc8ee0819f989acf9c3',imagePath: 'https://upload.wikimedia.org/wikipedia/en/5/5e/Gothiccover.png',title: 'Gothic Video',description: 'Absolutely stunning',price: 10,__v: 0
},image: 'https://upload.wikimedia.org/wikipedia/en/5/5e/Gothiccover.png',qty: 1,id: '5c863cc8ee0819f989acf9c3'
}]
console.log将输出以下结果(req.params.id):
5c863cc8ee0819f989acf9c3
每次用户单击关闭按钮时,都应调用此delete方法并删除整个对应的对象.然后在客户端服务器端输出更新的列表.任何可以指出我正确方向的人.
最佳答案