I have to subscribe twice on ngOnInit() in my component.ts but it seems that you can only subscribe once. The second subscription is ignored.
How can I solve that?
I tested it and changed the function and always the first subscription works the second is ignored..
It is just a dummy code, so do not wonder because of strange naming.
//service.service.ts
getUser(id: string){
return this.http.get(this.url)
}
getOrder(){
return this.http.get(this.anotherUrl)
}
//component.ts
constructor(private service: Service){}
public user: object;
public order: object;
public userID: string;
ngOnInit(){
this.userID = this.route.snapshot.params['id'];
this.service.getUser(this.userID).subscribe(user => { this.user = user });
this.service.getOrder().subscribe(order => { this.order = order });
}
This would not work. Only the first subscription would work and the second would be ignored.
What can I do about it? How would it be right?
Thank you