Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add action to postfetch function params #166

Open
jakeaaron opened this issue Aug 10, 2017 · 8 comments
Open

Add action to postfetch function params #166

jakeaaron opened this issue Aug 10, 2017 · 8 comments

Comments

@jakeaaron
Copy link

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?

@lexich
Copy link
Owner

lexich commented Aug 10, 2017

Hi @jakeaaron Very interesting question. I think that at this moment postfetch is only way.

@lexich
Copy link
Owner

lexich commented Aug 10, 2017

But it's good feature request

@lexich lexich mentioned this issue Aug 10, 2017
8 tasks
@jakeaaron
Copy link
Author

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?

@lexich
Copy link
Owner

lexich commented Aug 10, 2017

There is another way. You can use https://github.com/lexich/redux-api/blob/master/docs/DOCS.md#responsehandler and implement here retry logic

@jakeaaron
Copy link
Author

Oh! I didn't realize... you can dispatch an action in responseHandler?

@lexich
Copy link
Owner

lexich commented Aug 10, 2017

Yes responsehandler is bad idea in this case. But you can write custom adapter and you'll have access to request properties.

@jakeaaron
Copy link
Author

2 questions:

  1. Does post fetch not get called on a fetch failure?
  2. Do you think it would be sufficient to just return the action type since we're already returning the request?

@lexich
Copy link
Owner

lexich commented Aug 11, 2017

  1. Yes, postfetch called only on success.
  2. I didn't understand, what's you mean, maybe example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants