Open christopher-francisco opened 6 years ago
You shouldn't use redux-api-middleware
's action types to dispatch such actions. However, you can catch the success action somewhere (you can choose from writing a middleware handling this, using redux-saga, and so on). redux-api-middleware
allows you to pass a function to payload
as well, which will be called on successful server response - you can experiment with placing a thunk into there but unfortunately, I didn't test it by myself.
Would this approach work for you? (note: depends on redux-thunk)
dispatch(myRequestActionCreator()).then(action => {
if (action.error) {
// handle error
} else {
return dispatch(followupActionCreator())
}
})
See more at https://github.com/agraboso/redux-api-middleware#dispatching-thunks
Let us know if this helps, or if there's something you'd like better explained/documented!
On a "delete resource" context, Success need to call for loading once again. In my case, it also has to close the confirm dialog. Can I dispatch multiple actions on success?