migrated leaderboard api

This commit is contained in:
Nouman Tahir 2021-07-05 14:34:40 +05:00
parent 3463b55fcb
commit e98c83cf0f
3 changed files with 14 additions and 17 deletions

View File

@ -34,7 +34,7 @@ class LeaderboardContainer extends PureComponent {
const { isConnected } = this.props;
if (isConnected) {
this._fetchLeaderBoard();
this._fetchLeaderBoard('day');
}
}

View File

@ -18,7 +18,11 @@ api.interceptors.request.use((request) => {
console.log('Starting ecency Request', request);
//skip code addition is register and token refresh endpoint is triggered
if(request.url === '/signup/account-create' || request.url === '/auth-api/hs-token-refresh'){
if(request.url === '/signup/account-create'
|| request.url === '/auth-api/hs-token-refresh'
|| request.url.startsWith('private-api/leaderboard')
){
return request
}
@ -35,8 +39,6 @@ api.interceptors.request.use((request) => {
}
request.data.code = accessToken;
console.log('Added access token:', accessToken);
} else {
console.warn('No access token available');
}
return request;

View File

@ -301,19 +301,14 @@ export const getFragments = async () => {
* ************************************
*/
export const getLeaderboard = (duration) =>
api
.get('/leaderboard', {
params: {
duration,
},
})
.then((resp) => {
return resp.data;
})
.catch((error) => {
bugsnag.notify(error);
});
export const getLeaderboard = async (duration:'day'|'week'|'month') => {
try{
const response = await ecencyApi.get(`private-api/leaderboard/${duration}`)
return response.data;
} catch(error) {
bugsnag.notify(error)
}
}
export const getActivities = (data) =>
new Promise((resolve, reject) => {