I'm facing a unique issue and struggling to find someone who has encountered the same problem, which could imply that I am approaching it incorrectly.
The http request I am making looks like this:
return this.httpClient.post(`${this.route}/typegroups`, JSON.stringify(typeGroup)).pipe(share());
I have two subscribers to the returning observable and I want both of them to be notified in case of an error (or success). Currently, only the first subscriber receives the error notification.
First subscriber:
obs.subscribe((next:any) => {
//Success Code
},
error => {
this.notificationService.showError(error.message)
})
The second subscriber
obs.subscribe(next => {
console.log("EVERYTHING WENT WELL")
},
error => {
console.log("ERROR")
},
() => console.log("COMPLETED"));
The first subscriber is receiving the error notification and executing the error method, while the second subscriber is executing the next method, leading to a false impression that everything went smoothly. Any thoughts on why this is happening? Is there a better approach to handle this situation?
Thank you in advance for any assistance, as I am currently brainstorming to find a resolution to this dilemma.