import axios from 'axios';
import { FETCH_USER } from './types';

const fetchUser = () => {
    axios.get('api/current_user');
};
import axios from 'axios';
import { FETCH_USER } from './types';

const fetchUser = () => {
    // dispatch action once request is completed
    return function(dispatch) {
        axios.get('/api/current_user')
        // wait for response from api and then dipatch action
        .then(res => dispatch(({ type: FETCH_USER, payload: res })));
    };
};
add first action creator and redux thunk