My rep is too low to comment on original thread. https://stackoverflow.com/a/39643244/10651767
When I use function copyToClipboard(val)
where val is taken from localstorage all I get in the clipboard is string "val" and not the value of val variable.
val= localStorage.getItem("val");
copyToClipboard(val);