Angular - API call made twice
Can someone explain to me why this code makes an API call twice? I'm using Angular 21 with SSR activated.
ngOnInit(): void {
if (this.appService.platform() === 'browser') {
const { confirmationToken } = this.activatedRoute.snapshot.params;
console.log('CALL NOW');
this.authService.registerConfirm(confirmationToken).subscribe({
complete: () => {
console.log('ENTER COMPLETE');
this.onRegisterConfirm.set('success');
setTimeout(() => {
console.log('REDIRECT');
window.location.href = window.location.origin;
}, 3000);
},
error: (error) => {
console.log(error);
console.log('ENTER ERROR');
this.onRegisterConfirm.set('error');
},
});
}
}