I have the following auto-generated code (NSwag Studio) - the only amendment is withCredentials
which I've added for Windows Auth (intranet app).
deleteObjective(id: number): Observable<ObjectiveDTO> {
let url_ = this.baseUrl + "/api/Objectives/{id}";
if (id === undefined || id === null)
throw new Error("The parameter 'id' must be defined.");
url_ = url_.replace("{id}", encodeURIComponent("" + id));
url_ = url_.replace(/[?&]$/, "");
let options_ : any = {
observe: "response",
responseType: "blob",
withCredentials: true,
headers: new HttpHeaders({
"Accept": "application/json"
})
};
return this.http.request("delete", url_, options_).pipe(_observableMergeMap((response_ : any) => {
return this.processDeleteObjective(response_);
})).pipe(_observableCatch((response_: any) => {
if (response_ instanceof HttpResponseBase) {
try {
return this.processDeleteObjective(<any>response_);
} catch (e) {
return <Observable<ObjectiveDTO>><any>_observableThrow(e);
}
} else
return <Observable<ObjectiveDTO>><any>_observableThrow(response_);
}));
}
everything else in the generated service works fine (this is the only delete) but this is literally not sending any traffic - in the Chrome Network pullout (F12) there is no call to the API and the API does not receive anything.
I am calling it from my component like this:
deleteObjective(): void {
if (confirm('Are you sure you want to delete this objective? This cannot be un-done.')) {
if (this.objective.id !== 0)
this.service.deleteObjective(this.objective.id);
for (var i = 0; i < this.objectives.length; i++) {
if (this.objectives[i] === this.objective) {
this.objectives.splice(i, 1);
}
}
}
}
and the splice is definitely working. If I put debugger
before the http request it calls it. There are no errors in the console.
Any ideas? I am new to angular but old to programming.