Hi Rj,

I don't have the time right now to rewrite your code. However, subscribing 
inside a subscribe is a big antipattern and should be avoided.
What you need is to make it a rxjs flow that uses composition.
the following is just a idea, not working code:

function demo() {
const url1 = '';
const payload = '';
const url2 = 
'http://ws.integration.banyantechnology.com/services/api/rest/GetQuotes';
const getQuote = () =>
this.http.post(url2, payload).pipe(
tap(getQuoteResponse => {
this.getQuoteResponse = getQuoteResponse;
if (this.getQuoteResponse.RatingCompleted === true) {
this.ratingCompleted = true;
}
})
);

const sub = this.http
.post(url1, payload)
.pipe(
tap(importForQuoteResponse => {
this.importForQuoteResponse = importForQuoteResponse;
this.loadId = this.importForQuoteResponse.Load.Loadinfo.LoadID;
}),
expand(() => (this.this.ratingCompleted ? empty() : getQuote()))
)
.subscribe();
}

Note, `tap` descibes a side-effect, you should limit those to a minimum to 
create maintainable code

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/c8ba4bde-1586-4824-a126-c515b7646165%40googlegroups.com.

Reply via email to