Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { LOGIN, LOGOUT } from "auth/actions/actionTypes.js";
- import { getError } from "shared/actions/error";
- import _ from "lodash";
- import axios from "axios";
- export const login = user => ({
- type: LOGIN,
- user
- });
- export const startLogin = data => {
- return dispatch => {
- return axios({
- url: "/api/People/login",
- method: "POST",
- data: {
- email: data.email,
- password: data.password
- }
- })
- .then(res => {
- window.sessionStorage.setItem("utkn", res.data.id);
- dispatch(
- login({
- token: res.data.id
- })
- );
- return res;
- })
- .catch(e => {
- dispatch(getError(e.response));
- });
- };
- };
Add Comment
Please, Sign In to add comment