mirror of
https://github.com/Unleash/unleash.git
synced 2024-10-18 20:09:08 +02:00
19 lines
517 B
JavaScript
19 lines
517 B
JavaScript
|
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));
|
||
|
}
|