We are using redux-promise-middleware and having some difficulty working out what to do about error handling, all errors returned as 400 codes are just handled as 'FULFILLED'. I get that this is probably the correct behaviour but surely there is a way to catch an error in a promise in this setup. As we are not using redux-thunk, I am specifically asking how you would handle say a 400 error being returned from a promise.
our setup is very basic but I'm sure we should be able to
const export doSomething = object => {
const promise = API.doSomething(object)
return {
type: "DO_SOMETHING",
payload: {promise: promise}
}
}
reducer
export default (state = initialstate, action) {
switch(action.type){
case "DO_SOMETHING_FULFILLED":
return action.payload
case "DO_SOMETHING_REJECTED":
return console.log(action.payload)
default:
return initialstate
}
any help is greatly appreciated.