Angular 5+ cannot save result form observable response

前端 未结 4 1734
刺人心
刺人心 2021-01-25 00:58

I have an Angular app which consumes data from a webapi. When i make a request then i get an typed observable.

now when i do this:

data: Product[];
produ         


        
4条回答
  •  情书的邮戳
    2021-01-25 01:39

    You can do it something like this , finally here will execute after getProductId is complete

    productService.getByProductId("061000957")
          .finally(() => console.log(this.data))
          .subscribe(res => {
               console.log(res);
               this.data = res; 
        });
    

    I use do and finally when I try to debug rxjs observable

提交回复
热议问题