Почему ошибка при вызове drawImage?
<body></body>
<script>
const canvas = document.createElement('canvas')
canvas.width = 400
canvas.height = 300
document.body.appendChild(canvas)
var ctx = canvas.getContext('2d')
const setBg = () => ctx.drawImage("https://mdn.mozillademos.org/files/225/Canvas_drawimage.jpg", 0, 0)
const background = document.createElement('img')
background.setAttribute('crossorigin', 'anonymous')
background.onload = setBg
const downloader = document.createElement('a')
downloader.style.display = 'none'
document.body.appendChild(downloader)
downloader.download = 'myimage.png'
setTimeout(() => {
ctx.drawImage("https://mdn.mozillademos.org/files/225/Canvas_drawimage.jpg", 0, 0)
save();
}, 2000)
function save() {
downloader.href = canvas.toDataURL()
downloader.click()
}
</script>