0

I am using below function to display images in my React app from blobs received from mysql. The thing is that that there is an information that btoa shouldn't be really used. How can I replace it tough?

const toBase64 = (arr: any) => {
  const qwe = btoa(
    arr?.reduce(
      (data: string, byte: number) => data + String.fromCharCode(byte)
    )
  );
  return `data:image/*;base64,${qwe}`;
};
export default toBase64;

  • 1
    Does this answer your question? [Convert a string to base64 in JavaScript. btoa and atob are deprecated](https://stackoverflow.com/questions/68849233/convert-a-string-to-base64-in-javascript-btoa-and-atob-are-deprecated) – asportnoy Oct 27 '22 at 15:48

0 Answers0