I have this condition where on click of a button , I make a fetch request which will give me a url of a file that needs to be downloaded. How do I achieve the same?
Fetch API will give me a link to a file which needs to be downloaded
Help would be appreciated
<Button
fluid={false}
size={"small"}
onClick={this.download}
>
Download
</Button>
download = async () => {
try {
let response = await fetch('/fetch/downloadurl');
let json = await response.json();
let url = json.url;
// Need to write the download code here
window.open(url); // not working
} catch (error) {
console.log(error);
}
};