FitTrackee/fittrackee_client/src/actions/stats.js

14 lines
483 B
JavaScript
Raw Normal View History

2018-06-12 12:51:23 +02:00
import FitTrackeeGenericApi from '../fitTrackeeApi'
import { setData, setError } from './index'
2018-06-12 12:51:23 +02:00
export const getStats = (userId, type, data) => dispatch => FitTrackeeGenericApi
.getData(`stats/${userId}/${type}`, data)
.then(ret => {
if (ret.status === 'success') {
dispatch(setData('statistics', ret.data))
} else {
dispatch(setError(`statistics: ${ret.message}`))
}
})
.catch(error => dispatch(setError(`statistics: ${error}`)))