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; const { isConnected } = this.props;
if (isConnected) { if (isConnected) {
this._fetchLeaderBoard(); this._fetchLeaderBoard('day');
} }
} }

View File

@ -18,7 +18,11 @@ api.interceptors.request.use((request) => {
console.log('Starting ecency Request', request); console.log('Starting ecency Request', request);
//skip code addition is register and token refresh endpoint is triggered //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 return request
} }
@ -35,8 +39,6 @@ api.interceptors.request.use((request) => {
} }
request.data.code = accessToken; request.data.code = accessToken;
console.log('Added access token:', accessToken); console.log('Added access token:', accessToken);
} else {
console.warn('No access token available');
} }
return request; return request;

View File

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