Skip to content

Commit

Permalink
🐛 Explicitly handle clipboard API not available case
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei committed Jul 14, 2023
1 parent d66771e commit cae439e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions javascript/api_payload_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@

async function copyText(copyText, copyButton) {
try {
if (!navigator.clipboard) {
throw ('Clipboard API not available, please make sure you are using HTTPS.');
}

await navigator.clipboard.writeText(copyText);
copyButton.innerHTML = "Copied!";
copyButton.classList.add('success');
Expand Down

0 comments on commit cae439e

Please sign in to comment.