How to download file after making api call to server in react/saga?

Viewed 42

I'm trying to make an api call to server and download file with successful response.

function downloadFilesComponent() {
   const {payload} = useSelector(state => state.reduxstore)

   const handleDownload = () => 
  {
   dispatch(action.downloadfile({id:fileId, filename: fileName})
  }

  return ({
     <button onClick={handleDownload}/>
     })
}

Once action reaches saga, i make a request with payload to API and have the response coming back from API as a octate stream,how can i handle this response to download .txt file? Please help. Thank you in advance.

0 Answers
Related