21 lines
553 B
JavaScript
21 lines
553 B
JavaScript
|
import * as ActionTypes from '../../constants';
|
||
|
import axios from 'axios';
|
||
|
|
||
|
const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000/api' : '/api';
|
||
|
|
||
|
export function getProjects() {
|
||
|
return (dispatch) => {
|
||
|
axios.get(`${ROOT_URL}/projects`, { withCredentials: true })
|
||
|
.then(response => {
|
||
|
dispatch({
|
||
|
type: ActionTypes.SET_PROJECTS,
|
||
|
projects: response.data
|
||
|
});
|
||
|
})
|
||
|
.catch(response => dispatch({
|
||
|
type: ActionTypes.ERROR,
|
||
|
error: response.data
|
||
|
}));
|
||
|
};
|
||
|
}
|