Hi guys I am writing this code
async function copyLink() {
const myToken = Cookies.get("token");
const linkAndToken = "somepage.com/earlyAccessPage/token?=" + myToken;
try {
await navigator.clipboard.writeText(linkAndToken);
console.log("Page URL copied to clipboard");
} catch (err) {
console.error("Failed to copy: ", err);
}
}
return (
<div css={button} onClick={copyLink}>
<span css={buttonText}>Copy Link</span>
</div>
);
};
It should copy "linkAndToken" variable value to my clipboard. In local it work correct but in production it show error like "TypeError: Cannot read property 'writeText' of undefined". Help me correct this function for production