当我提交订单时,JSON如下所示:
{
"QTY": "x",
"ID": "xxx",
"cart_type": "xxx"
}
但是我需要它看起来像以下内容:
{
data:{
"QTY": "x",
"ID": "xxx",
"cart_type": "xxx"
}
}
我的ts文件如下:
onAddtoCart(newOrder) {
console.log(newOrder);
this.loading = true;
this.mhttp.addToCart()
.subscribe((cart: any) => {
this.loading = false;
this.saveCartRef(cart.cartRef);
console.log(newOrder);
});
}
答案 0 :(得分:0)
您可以将newOrder
包裹在JS对象中,如下所示:
onAddtoCart(newOrder) {
const wrappedNewOrder = {data: newOrder}
// then the rest as before but using wrappedNewOrder
}