svrcekmichal / redux-axios-middleware

Redux middleware for fetching data with axios HTTP client
MIT License
920 stars 96 forks source link

How to handle _FAIL actions #70

Open tjhazel opened 7 years ago

tjhazel commented 7 years ago

I am following the same pattern used in the middleware-netcore-example. I see _FAIL constants in the app.ts actions file. I am attempting to send failures into state, but I am getting my wires crossed.

state: export type App = { readonly values: { name: string, value: number }[] _readonly errors: [{ message: string, code: number }]_ };

action: export type Action = { type: 'GET_VALUES_FAIL', payload: AxiosResponse } | ... };

reducer: case Actions.GET_VALUES_FAIL: return { ...state, _errors_: action.payload.data };

Ideally i would map the fail action to a list of errors in the state..my app i have a error message action that ties into App.errors. Just not sure now to move forward given the errors live in a different object in state. How can i add this error data to my state?

acrosson commented 6 years ago

@tjhazel what did you do to solve this?