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

Make repeated calls to the same endpoint/method #157

Open
jakeaaron opened this issue Jul 17, 2017 · 3 comments
Open

Make repeated calls to the same endpoint/method #157

jakeaaron opened this issue Jul 17, 2017 · 3 comments

Comments

@jakeaaron
Copy link

Hello,

I know I've commented on another issue before, but could you show how one could make concurrent calls to the same method?
You mentioned using request, but how does one update state with request responses?

Thanks very much for your time

@lexich
Copy link
Owner

lexich commented Jul 18, 2017

Hi, you should use your own reducer

Promise.all([
rest.data.request(1),
rest.data.request(2)
]).then(data => dispatch(sendCompositeData( data )))

@ghost
Copy link

ghost commented May 24, 2018

Hi @lexich , I have some doubts with this.

I have a component A that render two times a component B. In the component B, in its componentDidMount method, I make a POST request by redux-api. The problem is that both components get the same response, that one that resolves first.
Am I doing anything wrong? How can I fix it?

Here is my call in component B:

this.props.dispatch(api.actions.signature.post({}, { body: JSON.stringify(this.param) }, (err, data) => { this.setState({ signatureData: data }) }));

@lexich
Copy link
Owner

lexich commented May 24, 2018

Hi @agustin-vieta
There are different ways to solve your problem. First of all this lib is named "redux-api" and the best way to keep data is not to use component state and replace it with redux store.
Request e.g. you can call in component A, and components B will only get data from store.

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