Lambda-School-Labs/kansha-fe

View on GitHub
src/store/actions/recog-actions.js

Summary

Maintainability
A
0 mins
Test Coverage
import {axiosWithAuth } from '../../utils/axiosWithAuth';

export const RECOG_SEND_START = 'RECOG_SEND_START';
export const RECOG_SEND_SUCCESS = 'RECOG_SEND_SUCCESS';
export const RECOG_SEND_FAILURE = 'RECOG_SEND_FAILURE';

export const sendRecog = recognition => dispatch => {
    dispatch({ type: RECOG_SEND_START})
    axiosWithAuth()
      .post('/rec', recognition)
      .then(res => {
          dispatch({ type: RECOG_SEND_SUCCESS, payload: res.data});
      })
      .catch(err => {
          dispatch({ type: RECOG_SEND_FAILURE, payload: err});
      });
};