redux-api
redux-api copied to clipboard
Add action to postfetch function params
We already get request options in the function, but I am wanting to retry an action if the fetch fails. If we had the action in the postfetch I could just dispatch the action again.
Is there a different way to retry an action if it fails?
Hi @jakeaaron Very interesting question. I think that at this moment postfetch is only way.
But it's good feature request
Thanks for the response @lexich. I don't think it's possible with postfetch at this moment, because we're not getting the action type in the function. Is this correct?
There is another way. You can use https://github.com/lexich/redux-api/blob/master/docs/DOCS.md#responsehandler and implement here retry logic
Oh! I didn't realize... you can dispatch an action in responseHandler?
Yes responsehandler is bad idea in this case. But you can write custom adapter and you'll have access to request properties.
2 questions:
- Does post fetch not get called on a fetch failure?
- Do you think it would be sufficient to just return the action type since we're already returning the request?
- Yes, postfetch called only on success.
- I didn't understand, what's you mean, maybe example?