Descargar archivo y cambiar el nombre

PHOTO EMBED

Thu Apr 06 2023 13:53:12 GMT+0000 (Coordinated Universal Time)

Saved by @vquillay #javascript

import axios from 'axios'
import fileDownload from 'js-file-download'
export default function App() {
  const handleClick = (url, filename) => {
    axios.get(url, {
      responseType: 'blob',
    })
    .then((res) => {
      fileDownload(res.data, filename)
    })
  }
  return (
    <div className="App">
      <button onClick={() => {() => handleClick('https://avatars.githubusercontent.com/u/9919?s=280&v=4', 'sample')}}>
        Download the File</button>
    </div>
  );
}
content_copyCOPY

https://www.delftstack.com/es/howto/react/react-download-file/