const loadAppData = () => { return dispatch => { dispatch({ type: types.APP.LOAD_APP_DATA_START }); dataService .get('/api/applicationdata') .then(res => { dispatch({ type: types.APP.LOAD_APP_DATA_SUCCESS, data: res.data }); }) .catch(error => { dispatch({ type: types.APP.LOAD_APP_DATA_ERROR, data: error }); }); }; }
getTodos() { //call JsonPlaceholder api to demonstrate getting data from a server let self = this; let url = 'https://jsonplaceholder.typicode.com/todos' axios.get(url).then((response) => { self.setState({todos: response.data}); // console.log(self.state); }).catch((error) => { console.log(error); }); }
/* * Authentications */ export function login(username, password) { return dispatch => { dashboardApi.get("jakubmachnik/dashboard/1.0.0/login", { params: { username: username, password: password } }) .then((resp) => { dispatch(loginSuccess(username, resp.data.token)); }) .catch(() => { dispatch(loginError()); }); } }