File tree 1 file changed +14
-8
lines changed
1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -879,20 +879,26 @@ async function listChallengesByMember (memberId) {
879
879
// get search is paginated, we need to get all pages' data
880
880
let page = 1
881
881
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
+ }
889
895
const ids = result . data || [ ]
890
896
if ( ids . length === 0 ) {
891
897
break
892
898
}
893
899
allIds = allIds . concat ( ids )
894
900
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' ] ) ) {
896
902
break
897
903
}
898
904
}
You can’t perform that action at this time.
0 commit comments