title: Download images from a website with js as base64
body: <p>I tried it like this, but I get this error: <code>ORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.</code>. How can I fix that.</p>
  <pre class="lang-js prettyprint-override"><code>async function test(img){
      return new Promise((resolve, reject) =&gt; {
          img.crossOrigin = 'use-credentials';
          img.onload = function(){
              let canvas = document.createElement('canvas');
              let ctx = canvas.getContext('2d');
              canvas.height = img.naturalHeight;
              canvas.width = img.naturalWidth;
              ctx.drawImage(img,0,0);
              let data = canvas.toDataURL('image/jpeg')
              resolve(data)
          }
      })
  }
  console.log(await test(document.querySelectorAll('img')[0]))
  </code></pre>