Guest User

Untitled

a guest
Apr 10th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import { LOGIN, LOGOUT } from "auth/actions/actionTypes.js";
  2. import { getError } from "shared/actions/error";
  3. import _ from "lodash";
  4. import axios from "axios";
  5.  
  6. export const login = user => ({
  7. type: LOGIN,
  8. user
  9. });
  10.  
  11. export const startLogin = data => {
  12. return dispatch => {
  13. return axios({
  14. url: "/api/People/login",
  15. method: "POST",
  16. data: {
  17. email: data.email,
  18. password: data.password
  19. }
  20. })
  21. .then(res => {
  22. window.sessionStorage.setItem("utkn", res.data.id);
  23. dispatch(
  24. login({
  25. token: res.data.id
  26. })
  27. );
  28. return res;
  29. })
  30. .catch(e => {
  31. dispatch(getError(e.response));
  32. });
  33. };
  34. };
Add Comment
Please, Sign In to add comment