text: import axios from "axios";
  
  import {
    GET_PROFILE,
    PROFILE_LOADING,
    CLEAR_CURRENT_PROFILE,
    GET_ERRORS
  } from "./types";
  
  // Get current profile
  export const getCurrentProfile = () => dispatch => {
    dispatch(setProfileLoading());
    axios("/api/profile")
      .then(res =>
        dispatch({
          type: GET_PROFILE,
          payload: res.data
        })
      )
      .catch(err =>
        dispatch({
          type: GET_PROFILE,
          payload: {}
        })
      );
  };
  
  // Create Profile
  export const createProfile = (profileData, history) => dispatch => {
    axios
      .post("/api/profile", profileData)
      .then(() => history.push("/dashboard"))
      .catch(err => {
        dispatch({
          type: GET_ERRORS,
          payload: err.response.data
        });
      });
  };
  
  // Set Loading as True
  export const setProfileLoading = () => {
    return { type: PROFILE_LOADING };
  };
  
  // Clear Profile State
  export const clearCurrentProfile = () => {
    return { type: CLEAR_CURRENT_PROFILE };
  };
  