Javascript 角度删除-API未接收调用

Javascript 角度删除-API未接收调用,javascript,angular,asp.net-core-webapi,Javascript,Angular,Asp.net Core Webapi,我有以下自动生成的代码(NSwag Studio)-唯一的修改是我为Windows Auth(intranet应用程序)添加的带有凭据的 deleteObjective(id:number):可观察{ 让url_u3;=this.baseUrl+“/api/Objectives/{id}”; if(id==未定义| | id==空) 抛出新错误(“必须定义参数“id”); url=url=url。替换(“{id}”,encodeURIComponent(“+id)); url=url。替换(/[

我有以下自动生成的代码(NSwag Studio)-唯一的修改是我为Windows Auth(intranet应用程序)添加的带有凭据的

deleteObjective(id:number):可观察{
让url_u3;=this.baseUrl+“/api/Objectives/{id}”;
if(id==未定义| | id==空)
抛出新错误(“必须定义参数“id”);
url=url=url。替换(“{id}”,encodeURIComponent(“+id));
url=url。替换(/[?&]$/,“”);
让选项:任意={
观察:“回应”,
响应类型:“blob”,
事实上,
标题:新的HttpHeaders({
“接受”:“应用程序/json”
})
};
返回此.http.request(“delete”、url、选项).pipe(\u observableMergeMap((response:any)=>{
返回此.processDeleteObjective(response_);
})).pipe(_observeCatch((响应:任意)=>{
if(HttpResponseBase的响应实例){
试一试{
返回此.processDeleteObjective(response_);
}捕获(e){
返回(e);
}
}否则
返回ObservateThrow(响应ObservateThrow);
}));
}
生成的服务中的所有其他内容都可以正常工作(这是唯一的删除),但实际上没有发送任何流量-在Chrome Network Pull(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).subscribe(res => {
          for (var i = 0; i < this.objectives.length; i++) {
            if (this.objectives[i] === this.objective) {
              this.objectives.splice(i, 1);
            }
          }
        })
    }
  }
deleteObjective():void{
if(确认('您确定要删除此目标吗?无法取消此操作')){
如果(this.objective.id!==0)
this.service.deleteObjective(this.objective.id);
对于(var i=0;i
而且拼接确实在工作。如果我在http请求之前放置
调试器
,它会调用它。控制台中没有错误


有什么想法吗?我对angular很陌生,但对编程很熟悉。

当您从服务调用函数时,请确保您
subscribe()

只有在您subscribe

试着这样做:

  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);
            }
          }
        })
    }
  }
deleteObjective():void{
if(确认('您确定要删除此目标吗?无法取消此操作')){
如果(this.objective.id!==0)
this.service.deleteObjective(this.objective.id).subscribe(res=>{
对于(var i=0;i
您必须订阅deleteObjective函数返回的对象。啊!谢谢这很有道理。