scinote-web/app/javascript/packs/shared/actions/ActivitiesActions.js

25 lines
592 B
JavaScript
Raw Normal View History

2017-08-02 23:27:05 +08:00
import axios from "axios";
import { ACTIVITIES_PATH } from "../../app/routes";
import { GLOBAL_ACTIVITIES_DATA } from "./types";
2017-08-03 22:03:15 +08:00
function addActivitiesData(data) {
2017-08-02 23:27:05 +08:00
return {
type: GLOBAL_ACTIVITIES_DATA,
payload: data
};
}
export function getActivities(last_id = 0) {
return dispatch => {
let path = `${ACTIVITIES_PATH}?from=${last_id}`;
axios
.get(path, { withCredentials: true })
.then(response => {
dispatch(addActivitiesData(response.data));
})
.catch(error => {
console.log("get Activites Error: ", error);
});
};
}