@alanscodelog/utils
    Preparing search index...

    Function copyToClipboard

    • Copies text, JSON objects, images, or plain blobs to the user's clipboard.

      Note, it can throw either because navigation.clipboard is not supported or new Blob or ClipboardItem themselves throw.

      await copyToClipboard("Hello World!").catch(handleError)

      await copyToClipboard({ id: 101, roles: ["admin"] }).catch(handleError)

      const response = await fetch("https://example.com/image.png")
      const imageBlob = await response.blob()
      await copyToClipboard(imageBlob);

      Parameters

      • data: string | unknown[] | Blob | Record<string, unknown>
      • options: { mimeType?: string } = {}
        • OptionalmimeType?: string

          Optional explicit MIME type override for Blobs or custom formats

      Returns Promise<void>