Nowadays i have one function that makes a http request, when i have the response i do other http request that depends of the success result of the first request.
I have this structure:
onSubmit() {
this.service.get().subscribe((res) => {
this.service2.get().subscribe((res) => {
console.log(res);
}, (err) => {
this.toastr.error(err.statusText);
})
}, (err) => {
this.toastr.error(err.statusText);
});
}
I think this is hard to understand and i'm trying to make it in a more appropriete way.
There's a way to extract this in two functions, each with yours errors and concat with some Rxjs operator?