Calling another action from redux-saga

Viewed 12

I am working on a react application. My plan is that - I have a download button on front end , when that button is clicked I want to fetch some data from backend(api) as well as download it after the data is fetched.

So what I am doing is that the front end dispatches an action on button click. Then action sends it to saga watcher and then an api is called to fetch data from backend and data is retrieved and even saved in state using reducer.

Now my question is how do I download this data as well without any other button click on the same previous button click.

Front end - onClick={dispatch(downloadAction(payload))}

actions.js-const downloadAction = payload => ({type: 1 , payload})

saga.js-watcher function

mainsagafunction(payload){ try{ const repsonse = response from api dispatch an action to send it reducer to store the response } }

So how do I implement the download here.

1 Answers

can U reset payload data in your reducer ? or just a advice use redux for more easy..

Related