Call external function from store
Hello. I have some question. I need to call some error handler after my thunk get error from api. I think save function to store is bad idea, but pass error handler with props with every call is uncomfortably. Is there a way to call some external function from model?
Not sure if this is best practice, but I've made a ApiResponse object based on what error my backend returns, as I have to handle each error differently dependent on what type of error that is returned.
My service function returns an ApiResponse-object contains an enum for return success/error and the object interfaced to what my thunk/model wants to handle
If the object matches my interface I handle it in the model or let my AuditModel handle the error. It might be 'overworking' the handling, but it makes it easy for me to handle errors and make sure my data is correct
@Hatsunyan you could make use of the store injections to do this?
https://easy-peasy.now.sh/docs/api/thunk.html#dependency-injection
Hope that helps!