в product-item.ts handleAddToCart () {
(
this.cartService.addProductToCart(this.productItem._id, "5e9ef6e0de85ea6018f63107")).subscribe(() => {
this.msg.sendMsg(this.productItem)
})
в Cart.services.ts addProductToCart (productID: string, UserID: string) {
let apiVerb :string = "Post";
let cartID :string = "";
this._http.get(cartUrl+"/user/"+UserID).toPromise()
.then((data: any) => {
cartID = data.results.cartID;
apiVerb = "Patch";
}).catch(()=>{debugger}).finally(()=>{
});
if(apiVerb=="Patch")
return this._http.patch(cartUrl+"/"+cartID, {"product":productID});
else
return this._http.post(cartUrl, { "user":UserID,"product":productID });
}