I have a button, clicking it will make a service call. Finally I want to inform the user by email. The email will be made by another service call.
public submitForm = (data, selected = {} ) => {
console.log(data);
this.service['submit'].post({body: data}).subscribe(
() => { null },
error => {
console.log(error);
};
() => {
// second subscribe
this.service['email']['post']({ body: theForm.value }).subscribe(
() = > {
// data processing
}
);
}
);}
You see it is the nested subscribe. I use angular 5 and rxjs 5.5. How to avoid it?
UPDATE:
By the comment, I added the service code
public readonly service: SwaggerService
The actually all services are in asp.net web api, for example
[HttpPost]
[Route("email")]
public ActionResult postEmail([FromBody]EmailBody email)
{}