TypeError: Failed to construct 'ClipboardItem': Failed to convert value to 'Blob' TypeError: Failed to construct 'ClipboardItem': Failed to convert value to 'Blob' google-chrome google-chrome

TypeError: Failed to construct 'ClipboardItem': Failed to convert value to 'Blob'


assuming your message is string type, here is a demo code

your code would be

navigator.permissions.query({ name: 'clipboard-write' }).then(result => {    if (result.state === 'granted') {        const type = 'text/plain';        const blob = new Blob([message], { type });        let data = [new ClipboardItem({ [type]: blob })];        navigator.clipboard.write(data).then(function() {            $.growl.notice({ message: ResourceService.getKey("CopyToClipboardSuccess"), location: "tc", title: "" });        }, function() {            $.growl.error({ message: ResourceService.getKey("CopyToClipboardError"), location: "tc", title: "" });        });    }});

but Clipboard API and events are still working draft, I recommend using an alternatives like clipboard.js