title: How to display binary data as image in React?
body: <p>I am receiving a bindata from the Nodejs server and now from that I need to display an image.</p>
  
  <p>How can I achieve this? Is there any method to convert bindata to JPEG or any other format? Or is it possible to convert that in server and then send that image to react?</p>
  
  <p>Here's how I'm trying to display the binary data (<code>item.Image.data.data</code>) with an image tag:</p>
  
  <pre><code>&lt;img src={item.Image.data.data} /&gt;
  </code></pre>
  
  <hr>
  
  <p>This is my detailed react code snippet:</p>
  
  <pre><code>componentDidMount(){
    let self = this;
    axios.get('http://localhost:8080/list')
      .then(function(data) {
        console.log(data);
        self.setState({post:data.data});
      });
  }
  
  &lt;ul className="w3-ul w3-card-4 w3-light-grey"&gt;
    { this.state.post.map((item, index) =&gt; {
      return (
        &lt;Link  to="/displaylist" style={{ textDecoration: 'none' }} key={index}&gt;
          &lt;li className=" w3-hover-green w3-padding-16" onClick={this.handleClick(item.Id)}&gt;
            &lt;img src={item.Image.data.data} className="w3-left w3-circle w3-margin-right" width="60px" height="40px" /&gt;
            &lt;span&gt;{item.Firstname}&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;
          &lt;/li&gt;
        &lt;/Link&gt;
        )}
    )}
  &lt;/ul&gt;
  </code></pre>
  
  <p>This is my nodejs code snippet:</p>
  
  <pre><code>server.get('/list', function(req, res) {
      databaseInterface.listStudent(function(err, students) {
        var myJSON = students;
  
        res.json(myJSON);
        // You should see the newly saved student here
      });
  });
  </code></pre>