我有以下自動生成的代碼 (NSwag Studio) - 唯一的修改是withCredentials我為 Windows Auth(內網應用程序)添加的代碼。 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_); })); }生成的服務中的其他一切工作正常(這是唯一的刪除),但這實際上沒有發送任何流量 - 在 Chrome 網絡拉出(F12)中,沒有對 API 的調用,API 也沒有收到任何內容。我從我的組件中調用它,如下所示: 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); } } } }并且拼接肯定是有效的。如果我放在debuggerhttp 請求之前,它會調用它??刂婆_中沒有錯誤。有任何想法嗎?我是 angular 的新手,但對編程很老。
角度刪除 - API 未收到調用
藍山帝景
2022-01-01 20:32:47