Angular http.post without .subscribe callback

后端 未结 5 2141
野的像风
野的像风 2020-12-05 23:56

I\'m wondering if I can make just a http post request without subscribing on callbacks, something like this

 this._http.post(\'/list/items/u         


        
5条回答
  •  独厮守ぢ
    2020-12-06 00:08

    You can simply use toPromise method like below:

    public getEmployerListFromService() {
        const url = `/list/items/update?itemId=`;
        return this.http.get(url).toPromise().then(response => {
          console.log(response);
        })
      }
    

    And Call this method by :

     this.service.getEmployerListFromService();
    

提交回复
热议问题