{"size": 602, "ext": "js", "max_stars_repo_path": "src/actions/loginActions.js", "max_stars_repo_name": "josiahbailey/login-crud-auth-practice", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/actions/loginActions.js", "max_issues_repo_name": "josiahbailey/login-crud-auth-practice", "max_issues_repo_issues_event_min_datetime": "2021-03-10T09:34:01.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-27T00:29:02.000Z", "max_forks_repo_path": "src/actions/loginActions.js", "max_forks_repo_name": "josiahbailey/login-crud-auth-practice", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 3, "max_forks_count": null, "avg_line_length": 22.2962962963, "max_line_length": 69, "alphanum_fraction": 0.6212624585}
import { axiosWithAuth } from '../utils/axiosWithAuth'

export const LOGIN_ATTEMPT = 'LOGIN_ATTEMPT'
export const LOGIN_SUCCESS = 'LOGIN_SUCCESS'
export const LOGIN_FAIL = 'LOGIN_FAIL'

export const login = user => dispatch => {
   dispatch({ type: LOGIN_ATTEMPT })
   axiosWithAuth()
      .post(`/login`, user)
      .then(res => {
         dispatch({ type: LOGIN_SUCCESS, payload: res.data.payload })
      })
      .catch(err => {
         dispatch({ type: LOGIN_FAIL, payload: err })
      })
}

export const LOGOUT = 'LOGOUT'

export const logout = () => {
   return {
      type: LOGOUT
   }
}

