How to replace in frontend Buffer.from(data, 'base64')?

To convert a binary string into an image, I use the Buffer.from(data, 'base64') construction in Node JS, it works perfectly. Now I'm trying to pass a similar string to the browser using this

<img src="data:image/jpeg;base64,${data}" />

and it doesn't work. In the API the ${data} looks like this:



  • Since I didn’t find anything smart, I just changed it and decided to do this formatting on the backend side (Node JS)

      const getUsersAttr = new Promise((resolve, reject) => {
        const ad = new ActiveDirectory(connLDP)
        ad.findUsers(fltLDP, function (err, users) {
          if (err) {
          } else if (!users || users.length == 0) {
            resolve('No users found')
          } else {
            for (let i = 0; i < users.length; i++) {
              if (users[i].thumbnailPhoto) {
                users[i].thumbnailPhoto = Buffer.from(users[i].thumbnailPhoto).toString('base64')
      return await getUsersAttr