I want to be able to remove an alert, but only if this alert is not assigned to an user. For that I need to get my users list and check if no user has this alert assigned. I managed to make it work by chaining 2 requests with observables, but is there a better way to achieve that?
deleteAlert(id: number) {
  this.usersService.getUsers().subscribe(
    (users) => {
      if (users.filter((value) => value.alert.id === id).length > 0) {
        console.log('Deassing alert to all user first');
      } else {
       this.alertService.deleteVillain(id)
        .subscribe(() => {
          this.alertsList =this.alertsList.filter(alerts=>alerts.id!==id);
        });
    }
  }
 )}