you're calling:
this.service.delete3("http://localhost:4200/").subscribe({
next: () => { console.log("test4"); },
error: () => { console.log("error test3"); }
});
You think it should log test4. But it doesn't... WHY????
Let's look inside delete3 in your service:
delete3(path: string): Observable<Company> {
console.log("delete3");
return this.http.delete<Company>(path);
}
You're logging "delete3" inside the function, not in the subscription. so if you never see "delete3" in console, it means..
drumroll please***
THE FUNCTION IS NEVER EVEN CALLED!!!!!! Like bro....... you thought you were calling it, but something else is broken and delete3() isn't even being triggered. So OF COURSE "test4" never shows up either.... you're not even getting to the .subscribe() block
console.log("about to call delete3");
this.service.delete3("http://localhost:4200/").subscribe({
next: () => { console.log("test4"); },
error: () => { console.log("error test3"); }
});
if you don't even see "about to call delete3" you're not reaching this part of code. Maybe some condition blocks it or user din't trigger it right.
HTTP DELETE (and POST/PUT) will still send the request... even if you dont subscribe() to it. But unless you subscribe(), the callback like next: () => {...}
won't run.
BUT WAIT... you are subscribing here. So thats not the issue
SOOOOO whats really happening is:
add some logs bro..
console.log("DELETE 1 start");
this.http.delete("http://localhost:4200/").subscribe({
next: () => { console.log("test"); },
error: () => { console.log("error test"); }
});
console.log("DELETE 2 start");
this.delete2("http://localhost:4200/").subscribe({
next: () => { console.log("test2"); },
error: () => { console.log("error test2"); }
});
console.log("DELETE 3 start");
this.service.delete3("http://localhost:4200/").subscribe({
next: () => { console.log("test4"); },
error: () => { console.log("error test3"); }
});
Now run it. Whichever "start" logs and whhichever domn't will tell what's actually being called.
TL;DR FOR THE LAZY
Bro test4 isnt logging because youre not even calling the service methd. You thought you were, but youre not. its like saying your microwave is broken, but you never plugged it in.
so yeah... super obvs lol