On below onclick event I am hitting the API to get the filepath and then passing that filepath to download method----
onClick={event =>
{ event.preventDefault();this.handleDownloadDoc('downloadAPI')}}>
Download method is :-
handleDownloadDoc = (function (fileName) {
var a = window.createElement("a");
window.body.appendChild(a);
a.style = "display: none";
return function (fileName) {
var json = JSON.stringify(fileName),
blob = new Blob([json], {type: "text/stream"}),
url = window.URL.createObjectURL(blob);
a.href = url;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(url);
};
}());
with above code I am getting error as does not create Element. Please help to fix this up.