p5.js-web-editor/client/modules/Sketch/actions.js
2016-07-01 11:30:40 -04:00

20 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
}));
};
}