Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
/**
* Copies a given string to the clipboard using
* the legacy exec method
*
* @param content The content to be copied
*/
export function copyToClipboard(content: string) {
if (navigator.clipboard) {
navigator.clipboard.writeText(content)
} else {
const dummy = document.createElement("textarea")
document.body.appendChild(dummy)
dummy.value = content
dummy.select()
document.execCommand("copy")
document.body.removeChild(dummy)
}
}