第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

角度刪除 - API 未收到調(diào)用

角度刪除 - API 未收到調(diào)用

藍山帝景 2022-01-01 20:32:47
我有以下自動生成的代碼 (NSwag Studio) - 唯一的修改是withCredentials我為 Windows Auth(內(nèi)網(wǎng)應用程序)添加的代碼。    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_);        }));    }生成的服務中的其他一切工作正常(這是唯一的刪除),但這實際上沒有發(fā)送任何流量 - 在 Chrome 網(wǎng)絡拉出(F12)中,沒有對 API 的調(diào)用,API 也沒有收到任何內(nèi)容。我從我的組件中調(diào)用它,如下所示:  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 請求之前,它會調(diào)用它。控制臺中沒有錯誤。有任何想法嗎?我是 angular 的新手,但對編程很老。
查看完整描述

2 回答

?
梵蒂岡之花

TA貢獻1900條經(jīng)驗 獲得超5個贊

當您從服務調(diào)用該函數(shù)時,請確保您subscribe()使用它。


查看完整回答
反對 回復 2022-01-01
?
慕標琳琳

TA貢獻1830條經(jīng)驗 獲得超9個贊

訂閱后才會命中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).subscribe(res => {

          for (var i = 0; i < this.objectives.length; i++) {

            if (this.objectives[i] === this.objective) {

              this.objectives.splice(i, 1);

            }

          }

        })

    }

  }


查看完整回答
反對 回復 2022-01-01
  • 2 回答
  • 0 關(guān)注
  • 173 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號