0

I'm trying to display an base64 image. It has to work in two different scenarios, but the image is just shown once.

Ejs is working fine:

<img id="host-img" src="data:image/<%=justtalk.image.contentType%>;base64,<%=justtalk.image.data.toString('base64')%>">

                                                                

Iterating through a loop doesn't work:

<script>
    const socket = io('/start');

    socket.on("receiveRooms", (room, callback) => {
        for(var i = 0; i < room.length; i++) {
            setTimeout("", 3000);
            var data2 = '<img id="host-img" src="data:image/'+room[i].image.contentType+';base64,'+room[i].image.data.toString('base64')+'"> '

                $(data2).prependTo('#');
                
        }    
    })
</script>

I can't see the difference

jakobheb
  • 23
  • 4

0 Answers0