I am working on a front-end project with Rxjs and Angular Framework and I want to get json data from a api "api/data_processor_classlib.php....". There are three parts was subscribed the pipe this.webProtectionHTML$ at HTML. I don't know why the pipe this.webProtectionHTML$ made requests 3 times. Is any possible solution that just sent one request and update all data in HTML? Thanks.
HTML Code:
<div class="tr">
<div class="align-left">Phishing & Other Frauds</div>
<div class="align-right">{{ (webProtectionHTML$|async)?.phishing}}</div>
</div>
<div class="tr">
<div class="align-left">Spam URLs</div>
<div class="align-right">{{ (webProtectionHTML$|async)?.spamURLs}}</div>
</div>
<div class="tr">
<div class="align-left">Malware Sites</div>
<div class="align-right">{{ (webProtectionHTML$|async)?.malware}}</div>
</div>
Component:
this.webProtectionHTML$ = this.dayService$
.pipe(
mergeMap((days: DaysPeriod // params added to request url) => this.httpClient.get(`api/data_processor_classlib.php....`//request url, { responseType: 'text' })),
map((html: string) => {
//get html code and find data return as json data
let result = this.getWebProtectionData(html)
return result
}))
Network log: