1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-08-04 18:35:17 +02:00
flame/client/src/store/actions/app.ts

25 lines
476 B
TypeScript
Raw Normal View History

2021-05-10 19:02:16 +02:00
import axios from 'axios';
import { Dispatch } from 'redux';
import {
GET_APPS,
GET_APPS_SUCCESS,
GET_APPS_ERROR
} from './actionTypes';
export const getApps = () => async (dispatch: Dispatch) => {
dispatch({ type: GET_APPS });
try {
const res = await axios.get('/api/apps');
dispatch({
type: GET_APPS_SUCCESS,
payload: res.data.data
})
} catch (err) {
dispatch({
type: GET_APPS_ERROR,
payload: err.data.data
})
}
}