I feel like I might be missing something simple. I am trying to get a text from the clipboard using the Async Clipboard Api but for the same strange reason, the operation is failing without any error messages.

I have a simple script that gets a text from the clipboard and then logs to console.

navigator.clipboard.readText()
    .then(data => {
        console.log('Text copied to clipboard', data);
    }).catch(err => {
    console.error("error copying text", err);
});

This fails with the message error copying text undefined.

In my manifest, I have requested the clipboardRead permission

  "permissions": [
    "clipboardRead"
  ]

What am I doing wrong?

0 Answers