Files
flood/client/source/scripts/actions/FloodActions.js
T
2016-06-05 10:33:59 -07:00

53 lines
1.2 KiB
JavaScript

import axios from 'axios';
import AppDispatcher from '../dispatcher/AppDispatcher';
import ActionTypes from '../constants/ActionTypes';
const FloodActions = {
fetchTransferData: () => {
return axios.get('/stats')
.then((json = {}) => {
return json.data;
})
.then((transferData) => {
AppDispatcher.dispatchServerAction({
type: ActionTypes.CLIENT_FETCH_TRANSFER_DATA_SUCCESS,
data: {
transferData
}
});
})
.catch((error) => {
AppDispatcher.dispatchServerAction({
type: ActionTypes.CLIENT_FETCH_TRANSFER_DATA_ERROR,
data: {
error
}
});
});
},
fetchTransferHistory: (opts) => {
return axios.get('/history', {
params: opts
})
.then((json = {}) => {
return json.data;
})
.then((data) => {
AppDispatcher.dispatchServerAction({
type: ActionTypes.CLIENT_FETCH_TRANSFER_HISTORY_SUCCESS,
data
});
})
.catch((error) => {
AppDispatcher.dispatchServerAction({
type: ActionTypes.CLIENT_FETCH_TRANSFER_HISTORY_ERROR,
error
});
});
}
};
export default FloodActions;