You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is related to #152, that have been merged in version 0.10.7
If several actions are bound to the same reducer (with the reducerName option), the pathvars and body will contain the latest action done on it. That might not be the expected behaviour.
Example :
constrest=reduxApi({getUser: {reducerName: "user"url: "/user/:id",// return a user object},updateUser: {reducerName: "user"url: "/user/:id/update",options: {method: "post"},transformer: function(data,prevData,action){/* update the store content based on the data received */}}});/* ... */dispatch(rest.actions.getUser({id:1}));// store will contain { pathvars: {id:1}, body: {} }dispatch(rest.actions.updateUser({id:1},{body: {message: 'hello world'}}));// store will contain { pathvars: {id:1}, body: {message: 'hello world'} }
The content of body is kinda weird : the store still contains the results of the first call, with the update.
It would make sense that the body stays empty.
This gets even worse with a poorly coded API, where updateUser does not contain any pathvar :
constrest=reduxApi({getUser: {reducerName: "user"url: "/user/:id",// return a user object},updateUser: {reducerName: "user"url: "/user/update",options: {method: "post"},transformer: function(data,prevData,action){/* update the store content based on the data received */}}});/* ... */dispatch(rest.actions.getUser({id:1}));// store will contain { pathvars: {id:1}, body: {} }dispatch(rest.actions.updateUser({id:1},{body: {user_id:1,message: 'hello world'}}));// store will contain { pathvars: {}, body: {user_id:1, message: 'hello world'} }
This can also be a problem when the request gives an error : pathvars and body will change, but not the content.
How should we handle such cases ?
The text was updated successfully, but these errors were encountered:
This issue is related to #152, that have been merged in version 0.10.7
If several actions are bound to the same reducer (with the
reducerName
option), the pathvars and body will contain the latest action done on it. That might not be the expected behaviour.Example :
The content of
body
is kinda weird : the store still contains the results of the first call, with the update.It would make sense that the
body
stays empty.This gets even worse with a poorly coded API, where
updateUser
does not contain any pathvar :This can also be a problem when the request gives an error :
pathvars
andbody
will change, but not the content.How should we handle such cases ?
The text was updated successfully, but these errors were encountered: