Promise.all()与地图,已静音

时间:2018-07-17 11:29:54

标签: javascript typescript es6-promise

实际上,我在Promises方面遇到问题,肯定会错过一个小姐。

我有一个包含ID列表的数组,我使用这些ID进行API调用,以确保它是有效的并且可以正常工作。因此,我必须在此列表中将foreach元素设为API调用=> Promise。

我读到了关于诺言的内容,并且找到了实现这种诺言的干净方法:

clean(){
/** Here, I'm just cleaning invalid ids to avoid a silenced map. I tried the 
whole output in the API explorator, and it works well*/
this.facebook.objectIdsToDelete.forEach(element => {
  let index = this.facebook.objectIdsToFilter.indexOf(element);
  this.facebook.objectIdsToFilter.splice(index, 1);
});

Promise.all(this.facebook.objectIdsToFilter.map(value=>{
  return this.facebook.callApiLikes(value);
}))
.then((responses) => {
  this.debogger.debogSomething(responses);
})
.catch((reason) => {
  this.debogger.debogSomething(reason);
})
}

debogger =>这是显示对象内容的弹出窗口。 this.facebook.objecIdsToFilter =>是字符串[]

此弹出窗口不显示,没有任何反应。 我在哪里做错了?

0 个答案:

没有答案