Why am I getting an "Uncaught DOM Exception" in the Deno CLI?
To replicate:
1.
deno
in the command line to initialize a Deno REPL
The goal was to get a base64 encoding of the byte array. What am I doing wrong? atob
produces the same result.1 Reply
Since arr is not guaranteed to contain valid utf-8, btoa will throw an error when it attempts to encode invalid text. According to stackoverflow, you can just use
instead
(https://stackoverflow.com/questions/9267899/arraybuffer-to-base64-encoded-string)
Stack Overflow
ArrayBuffer to base64 encoded string
I need an efficient (read native) way to convert an ArrayBuffer to a base64 string which needs to be used on a multipart post.