Hi @oliveira,
Welcome to our forums!
In order to perform the "copy to clipboard" action, you need to append a textarea in which you put the text, programmatically select the textarea, perform 'copy' action, and remove the textarea.
Below I have put an example function which should do this, including how you would implement this.
const copyToClipboard = str => {
const el = document.createElement('textarea');
el.value = str;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
};
// usage
copyToClipboard("mycoupon");
Let me know if this works for you!