I'm wondering how to successfully download an image using javascript. Every time I try, it shows a failed error message.
<div>
<button onClick=this.downloadImage(event, "http://example.net/media/image.png")>Download</button>
</div>
downloadImage = (event, image) => {
var link = document.createElement('a');
link.href = image.toDataUrl("image/png", 1.0);
link.download = 'Download.png';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}