scinote-web/app/javascript/packs/shared/actions/UsersActions.js
2017-08-09 09:08:13 +02:00

23 lines
527 B
JavaScript

import axios from "axios";
import { CURRENT_USER_PATH } from "../../app/routes";
import { SET_CURRENT_USER } from "./types";
function addCurrentUser(data) {
return {
type: SET_CURRENT_USER,
payload: data
};
}
export function getCurrentUser() {
return dispatch => {
axios
.get(CURRENT_USER_PATH, { withCredentials: true })
.then(({ data }) => {
dispatch(addCurrentUser(data.user));
})
.catch(error => {
console.log("get Current User Error: ", error);
});
};
}