This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
react-rest-request/target/reducer.js

14 lines
572 B
JavaScript
Raw Permalink Normal View History

export function requestReducer(state, action) {
switch (action.type) {
case 'call': {
return Object.assign(Object.assign({}, state), { loading: true, isCalled: true, prevHeaders: action.headers, prevVariables: action.variables, prevParams: action.params });
}
case 'success': {
return Object.assign(Object.assign({}, state), { loading: false, data: action.response.data });
}
case 'failure': {
return Object.assign(Object.assign({}, state), { loading: false, data: null });
}
}
}