I need to wait for first call, before start second request. I'm new in js so I think that it could be simple. I was read smth about async/await but i don't have idea how to implement it in this example
ngOnInit() {
this.firstService.get$(this.orderNumber).subscribe(
first => this.firstModel = first,
e => {
for (const error of e.errors) {
this.messages.push({
_type: MessageType.ERROR,
code: error.messageCode
});
}
}
);
this.secondService.getReasons$(this.firstModel).subscribe(
second => this.secondModel = second,
e => {
for (const error of e.errors) {
this.messages.push({
_type: MessageType.ERROR,
code: error.messageCode
});
}
}
);
}
this.firstModel
is undefined in second step.