Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/services/challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,22 @@ class ChallengesService {
},
};
};

const getChallengeDetails = async (
endpoint,
legacyInfo,
) => {
let query = '';
if (legacyInfo) {
query = `legacyId=${legacyInfo.legacyId}`;
}
const url = `${endpoint}?${query}`;
const res = await this.private.apiV5.get(url).then(checkErrorV5);
return {
challenges: res.result || [],
};
};

/**
* Private function being re-used in all methods related to getting
* challenges. It handles query-related arguments in the uniform way:
Expand Down Expand Up @@ -221,6 +237,7 @@ class ChallengesService {
apiV2: getApi('V2', tokenV2),
apiV3: getApi('V3', tokenV3),
getChallenges,
getChallengeDetails,
getMemberChallenges,
tokenV2,
tokenV3,
Expand Down Expand Up @@ -359,10 +376,10 @@ class ChallengesService {
// condition based on ROUTE used for Review Opportunities, change if needed
if (/^[\d]{5,8}$/.test(challengeId)) {
isLegacyChallenge = true;
challenge = await this.private.getChallenges('/challenges/', { legacyId: challengeId })
challenge = await this.private.getChallengeDetails('/challenges/', { legacyId: challengeId })
.then(res => res.challenges[0]);
} else {
challenge = await this.private.getChallenges(`/challenges/${challengeId}`)
challenge = await this.private.getChallengeDetails(`/challenges/${challengeId}`)
.then(res => res.challenges);
}

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy