@@ -186,6 +186,22 @@ class ChallengesService {
186
186
} ,
187
187
} ;
188
188
} ;
189
+
190
+ const getChallengeDetails = async (
191
+ endpoint ,
192
+ legacyInfo ,
193
+ ) => {
194
+ let query = '' ;
195
+ if ( legacyInfo ) {
196
+ query = `legacyId=${ legacyInfo . legacyId } ` ;
197
+ }
198
+ const url = `${ endpoint } ?${ query } ` ;
199
+ const res = await this . private . apiV5 . get ( url ) . then ( checkErrorV5 ) ;
200
+ return {
201
+ challenges : res . result || [ ] ,
202
+ } ;
203
+ } ;
204
+
189
205
/**
190
206
* Private function being re-used in all methods related to getting
191
207
* challenges. It handles query-related arguments in the uniform way:
@@ -221,6 +237,7 @@ class ChallengesService {
221
237
apiV2 : getApi ( 'V2' , tokenV2 ) ,
222
238
apiV3 : getApi ( 'V3' , tokenV3 ) ,
223
239
getChallenges,
240
+ getChallengeDetails,
224
241
getMemberChallenges,
225
242
tokenV2,
226
243
tokenV3,
@@ -359,10 +376,10 @@ class ChallengesService {
359
376
// condition based on ROUTE used for Review Opportunities, change if needed
360
377
if ( / ^ [ \d ] { 5 , 8 } $ / . test ( challengeId ) ) {
361
378
isLegacyChallenge = true ;
362
- challenge = await this . private . getChallenges ( '/challenges/' , { legacyId : challengeId } )
379
+ challenge = await this . private . getChallengeDetails ( '/challenges/' , { legacyId : challengeId } )
363
380
. then ( res => res . challenges [ 0 ] ) ;
364
381
} else {
365
- challenge = await this . private . getChallenges ( `/challenges/${ challengeId } ` )
382
+ challenge = await this . private . getChallengeDetails ( `/challenges/${ challengeId } ` )
366
383
. then ( res => res . challenges ) ;
367
384
}
368
385
0 commit comments