Home > OS >  angular - Why using the data and error on the subscribe/observable like this is deprecated?
angular - Why using the data and error on the subscribe/observable like this is deprecated?

Time:06-03

Why is this deprecated? and how is the correct form?

 getPeopleFunction() {
this.peopleService.getPeopleService().subscribe(
  (data) => {
    console.log(data);
  },
  (error) => {
    console.log(error);
  }
);

}

CodePudding user response:

You should use this format now:

this.peopleService.getPeopleService().subscribe({
    next: (v) => console.log(v),
    error: (e) => console.error(e),
    complete: () => console.info('complete') 
})

https://rxjs.dev/deprecations/subscribe-arguments

  • Related