Having an issue with calling a function that listens to the event onBeforeUnload() and trying to post data using an httpClient request. However, the request is not being sent correctly. Here's the code snippet:
@HostListener('window:beforeunload', ['$event'])
onBeforeUnload(): void {
this._httpClient.post(`${localhost:8080/apiRest}`, infoIWantToSent).subscribe();
}
Seeking guidance on whether this approach is correct. Any help would be appreciated. Thank you.