Reputation: 1865
I am using redux to store data from an api and in the very next step i need to get the stored data.
this.props.fetchdata(id) // initiates the action to call the api, stores the api response in store.
this.props.details // gets the stored data from store
I need to invoke both the calls one after another in componentDidMount so that i have the data in store before 2 is called. How to implement that??
Upvotes: 0
Views: 41
Reputation: 2464
You can try async
await
pattern:
async componentDidMount(){
await this.props.fetchdata(id);
this.props.details();
But i dont understand, if you have data from api, use it directly without waiting to store it in redux and then getting it back from store.
Upvotes: 1