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

15 lines
496 B
JavaScript
Raw Normal View History

export const AUTH_REQUIRED = 'AUTH_REQUIRED';
export const FORBIDDEN = 'FORBIDDEN';
export function dispatchAndThrow(dispatch, type) {
return error => {
if (error.statusCode === 401) {
dispatch({ type: AUTH_REQUIRED, error, receivedAt: Date.now() });
} else if (error.statusCode === 403) {
dispatch({ type: FORBIDDEN, error, receivedAt: Date.now() });
} else {
dispatch({ type, error, receivedAt: Date.now() });
}
};
}