1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/frontend/src/store/context/actions.js

19 lines
517 B
JavaScript
Raw Normal View History

import api from '../../data/context-api';
import { dispatchAndThrow } from '../util';
export const RECEIVE_CONTEXT = 'RECEIVE_CONTEXT';
export const ERROR_RECEIVE_CONTEXT = 'ERROR_RECEIVE_CONTEXT';
export const receiveContext = json => ({
type: RECEIVE_CONTEXT,
value: json,
});
export function fetchContext() {
return dispatch =>
api
.fetchContext()
.then(json => dispatch(receiveContext(json)))
.catch(dispatchAndThrow(dispatch, ERROR_RECEIVE_CONTEXT));
}