-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Where to pass onSuccess, onComplete, etc? #78
Comments
@djalmaaraujo I came here to ask the same question. I can see an issue here which has a little information about it. #7 I think one of the below ways might be what you are after. Just append _SUCCESS or _FAIL to your action eg ORDER_SUBMIT_SUCCESS or ORDER_SUBMIT_FAIL (these are built in to the module) I have a saveComment function which is triggered when the user click save.
I then have
Or If you are using dispatch (see the res output below)
res output
|
Thanks @azza85. I still feel odd that we need a setting to have the .catch() to work. Why this is not the default? |
you'll want to do something like this: type: ORDER_SUBMIT,
payload: {
request: {
method: 'put',
url: `/tickets/${orderData.orderTicketCode}`,
data: {}
},
options: {
onSuccess({ getState, dispatch, response }) {
dispatch({ type: `${ORDER_SUBMIT}_SUCCESS`, payload: response.data });
},
onError({ getState, dispatch, error }) {
dispatch({ type: `${ORDER_SUBMIT}_FAILURE`, payload: error.response });
},
}
} |
@marcusmolchany Thank you. This should've been in the documentation. |
manually dispatching a new action in |
I am trying to have callbacks, but it's not working in the object:
Where is the correct location?
The text was updated successfully, but these errors were encountered: