-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
How to get response data after mutation without custom reducer. #305
Comments
With const doSaveQuestion = question => ({
type: SAVE_QUESTION,
request: {
url: `/api/questions`,
method: 'POST',
data: question,
},
meta:
id: question.id,
mutations: {
[FETCH_QUESTION]: {
updateData: (state, action) =>
state.data.map(v => v.id === action.meta.id ? action.data : v),
},
},
}); I can totally understand though it is confusing. In the future version only Also there won't be any internal state in |
Thank you for your quick reply. I trigger this action on form submission, so I don't have an ID yet. I tried the mutation in the doSaveQuestion action but the updateData function doesn't gets called. |
See example especially this file and line to see mutations in action https://github.com/klis87/redux-saga-requests/blob/master/examples/mutations/src/store/actions.js#L61 |
Regarding id I though doSaveQuestion is for updating. If this is for creation, then update data could just append new question so id is not necessary then |
I'm using mutations with delete, they work as they should, but no luck with post requests. Thanks! |
Logic should be exactly the same, if u still have issues pls make minimal reproducing repo so I could take a look |
@svindler let me know if sth does not work, it really should, especially in v0.27.0 |
Hello,
I'm using the networkReduxer, but after reading the docs couple times can't find an easy way to get the data after a mutation without creating a custom reducer.
These are my actions:
Please point me to the right directon.
Thanks!
The text was updated successfully, but these errors were encountered: