I have created a function to download the file, but the issue is it opens the file on the same tab, I a trying to force download this file in the system. I read other threads but didn't get the answer as I was expected and helpful.
Please help me create this function that downloads the file. I have tried this code as below
function downloadURI(uri, name) {
var link = document.createElement("a");
link.download = 'name';
link.href = uri;
link.click();
link.remove();
}
downloadURI('https://example.com/myfile.pdf', 'customefilename.pdf');