如何从http响应中找到任何数组对象中的出现

时间:2018-10-24 07:41:44

标签: angular

我需要从HTTP响应中找到OpenIn ProgressResolvedClosed的计数。

响应的预期输出

Open = 1;
In Progress = 1;
Resolved = 1;
Closed = 1

下面是我的功能

getJiraOpenIssues(id:string, status:string) {
  return this.http.get<any>( apiUrl + this.auth)
  .subscribe(count => console.log(count));
}

HTTP响应

{
"expand": "schema,names",
"startAt": 0,
"maxResults": 100,
"total": 184,
"issues": [
    {
        "status": {
            "name": "Open"
        }
    },
    {
        "status": {
            "name": "In Progress"
        }
    },
    {
        "status": {
            "name": "Resolved"
        }
    },
    {
        "status": {
            "name": "Closed"
        }
    }
]
}

更新

  getJiraOpenIssues(id:string, status:string) {
    return this.http.get<any>( apiUrl + this.auth)
    .subscribe(response => {
      let a = new Map(...new Set<any>(response).map(
        x => [x, this.response.issue.filter(y => y === x).length]
      ));
    });
  }

使用上述功能,我会收到此错误

[ts]类型“设置”上不存在属性“地图”。

0 个答案:

没有答案