Skip to content

Commit bc39ec2

Browse files
Merge pull request #511 from topcoder-platform/fix-listmemberchallenges-master
captuer the listchallengesbymember call
2 parents bcf862f + 71c6d59 commit bc39ec2

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/common/helper.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -879,20 +879,26 @@ async function listChallengesByMember (memberId) {
879879
// get search is paginated, we need to get all pages' data
880880
let page = 1
881881
while (true) {
882-
const result = await axios.get(`${config.RESOURCES_API_URL}/${memberId}/challenges`, {
883-
headers: { Authorization: `Bearer ${token}` },
884-
params: {
885-
page,
886-
perPage: 10000
887-
}
888-
})
882+
let result = {};
883+
try {
884+
result = await axios.get(`${config.RESOURCES_API_URL}/${memberId}/challenges`, {
885+
headers: { Authorization: `Bearer ${token}` },
886+
params: {
887+
page,
888+
perPage: 10000
889+
}
890+
})
891+
} catch (e) {
892+
// only log the error but don't throw it, so the following logic can still be executed.
893+
logger.debug(`Failed to get challenges that accessible to the memberId ${memberId}`, e)
894+
}
889895
const ids = result.data || []
890896
if (ids.length === 0) {
891897
break
892898
}
893899
allIds = allIds.concat(ids)
894900
page += 1
895-
if (result.headers['x-total-pages'] && page > Number(result.headers['x-total-pages'])) {
901+
if (result.headers && result.headers['x-total-pages'] && page > Number(result.headers['x-total-pages'])) {
896902
break
897903
}
898904
}

0 commit comments

Comments
 (0)