Home > Mobile >  How to render image on react client side send from express js
How to render image on react client side send from express js

Time:02-05

I want to display the image in page send from server, but what I am receiving on client side are thousands of strange characters (possibly blob). I'm using react on client side. I am sending data using res.sendfile() method. If there's any other strategy, then please share.

CodePudding user response:

if you received multiple charters then it is base64. you can render images with base64.

render(){
    {this.state.image ? <img src={`data:image/png;base64,${this.state.image}`}/>: ''}
}

if the image response is not base64 then you need to convert blob to base64.

  •  Tags:  
  • Related