react-redux-realworld-example-app
react-redux-realworld-example-app copied to clipboard
Create and Update article error handling problem
I seem to be getting a problem if I try to create or update an article when I force an error, eg the form I submit has a blank body and description. The 422 response from the back-end is acknowledged, but the UI appears to continue to its next steps, eventually crashing with a "Cannot read property of slug" error.
Here's the 422 response received: {"errors":{"description":["can't be empty"],"body":["can't be empty"]}}
and here's the UI console log:
POST http://192.168.1.75:3000/api/articles 422 (Unprocessable Entity)
middleware.js:33 ERROR Error: Unprocessable Entity
at PromiseRequest.
action ASYNC_END @ 17:04:08.438 core.js:116
prev state Object {article: Object, articleList: Object, auth: Object, common: Object, editor: Object…} core.js:120
action Object {type: "ASYNC_END", promise: Object} core.js:128
next state Object {article: Object, articleList: Object, auth: Object, common: Object, editor: Object…} core.js:104
action ARTICLE_SUBMITTED @ 17:04:08.440 core.js:116
prev state Object {article: Object, articleList: Object, auth: Object, common: Object, editor: Object…} core.js:120
action Object {type: "ARTICLE_SUBMITTED", payload: Object, error: true} core.js:124
error TypeError: Cannot read property 'slug' of undefined
at exports.default (common.js:40)
at combination (combineReducers.js:132)
at dispatch (createStore.js:179)
at index.js:104
at middleware.js:60
at middleware.js:46
at Object.dispatch (applyMiddleware.js:45)
at middleware.js:39 core.js:128
next state Object {article: Object, articleList: Object, auth: Object, common: Object, editor: Object…}
common.js:40 Uncaught (in promise) TypeError: Cannot read property 'slug' of undefined
at exports.default (common.js:40)
at combination (combineReducers.js:132)
at dispatch (createStore.js:179)
at index.js:104
at middleware.js:60
at middleware.js:46
at Object.dispatch (applyMiddleware.js:45)
at middleware.js:39
The odd thing is I don't appear to get this behaviour when running the demo at react-redux.realwold.io, even though the responses coming from the back-end appear essentially the same.