Мне нужно обещание выполнить сначала, а затем после этого возврата, потому что это непосредственно go по возвращении, поэтому сообщение всегда будет первым исполненным - PullRequest
0 голосов
/ 29 апреля 2020

в 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 });
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...