I have this link https://carbon-copies-restapi.herokuapp.com/all-order-histories.txt which contains some data. I want to download it as a file using React. I tried many solutions from StackOverflow but nothing worked for me. One of the solutions I found on the internet that did not work either.
const downloadFile = async () => { fetch( "https://carbon-copies-restapi.herokuapp.com/all-order-histories.txt" ).then((response) => { response.blob().then((blob) => { let url = window.URL.createObjectURL(blob); let a = document.createElement("a"); a.href = url; a.download = "orders.txt"; a.click(); }); //window.location.href = response.url; }); };