Closed alparslanahmed closed 7 years ago
Can you explain what you are trying to accomplish? Why do you want to override the onSuccess() handler?
@nmaves i wished to handle API errors from single function this means i don't need to execute notification function for showing notification to user on every action. I just wanted to write clean code. I don't know this is a proper solution but i fixed it for my code like this:
onSuccess: function ({ action, next, response, error, dispatch }, options) {
if (!response.data.Response && response.data.Header && response.data.Header.errors) {
dispatch(actions.apiError(response.data.Header.errors));
} else {
dispatch(actions.ajaxReponse(response.data));
}
dispatch({
type: action.type + types._SUCCESS,
payload: response.data.Response
});
}
When i dispatch action with type and request everything seems ok. I am transforming request with transformRequest and after request finish onSuccess and onError methods working well. But there is no action fires with '_SUCCESS' or '_ERROR' suffix. What could be my mistake?
action Object {type: "AJAX_RESPONSE", data: Object}