I'm facing an issue with the following code:
ComputerValue: number;
private subscription: ISubscription;
ngOnInit() {
this.getMyValue();
setInterval(() => {
this.getMyValue();
}, 30000);
}
getMyValue(): void {
this.subscription = this.dataService.getValueOfComputer().subscribe(data => {
console.log(data);
this.ComputerValue = data;
});
}
After checking my console, I noticed that the result is being displayed twice because it seems like my HTTP query inside the subscribe function is executing twice. This has been puzzling me.
https://i.sstatic.net/NFGca.png
Any suggestions on how to resolve this?
Thank you in advance!