我有一个 aysnc 函数,它获取数据并返回Promise.all
ie的值
const fetchDownloadMenuData = async selectedItems => {
return Promise.all(
selectedItems.map(async item => {
try {
if (item.id === 'interviewGuide') {
const interviewGuide = await positionCandidatesService.getCandidate(
positionId,
candidateSelected.id
);
return interviewGuide.interviewGuide;
}
if (item.id !== 'overview' && item.id !== 'profile') {
const outcome = await outcomesService.get(candidateSelected.id, item.id);
return outcome;
}
return null;
} catch (err) {
appInsights.trackException({
error: new Error(`Error fetching candidate outcome: ${JSON.stringify(err)}`)
});
return null;
}
})
)};
我这样称呼这个函数:
try {
downloadData = await fetchDownloadMenuData(selectedItems);
} catch (err) {
appInsights.trackException({
error: new Error(`Could not fetch all PDF data: ${JSON.stringify(err)}`)
});
return;
}
但它永远不会被捕获。为什么是这样?如果所有的承诺都没有解决,我如何让它拒绝?
谢谢