Paste image from clipboard to a variable

Update , this worked.
Pasting it for anyone who needs it

navigator.clipboard.read()
  .then(items => {
    for (const item of items) {
      if (item.types.includes('image/png') || item.types.includes('image/jpeg')) {
        item.getType(item.types[0])
          .then(blob => {
            const reader = new FileReader();
            reader.onload = () => {
              variables['a947901f-9002-4fd7-b3ba-142fc68c464f'] = reader.result;
            };
            reader.readAsDataURL(blob);
          });
      }
    }
  });
1 Like