title: Serve images using express or send binary data to client
body: <p>I'm not sure about best practices to go about displaying images stored in MongoDB database.</p>
  
  <p>I have a user uploading an image through React then that is sent to an express server via an API call. Then I use multer to get the buffer data and send that to MongoDB.</p>
  
  <p>Currently, to display an image on the front-end I use express to serve up the image. Meaning I can access any image in mongo by typing '<a href="http://localhost:3000/api/image/" rel="nofollow noreferrer">http://localhost:3000/api/image/</a><em>image_id</em></p>
  
  <p>With that being said in the front end. I have an API call which grabs all the images Ids and then use them to create a link. Something like this.</p>
  
  <pre><code>constructor(props) {
      super(props)
      this.state = {
          imgID: ''
      }
  }
  
  render() {
      return (
          &lt;img src={"http://localhost:3000/api/image/" + this.state.imgID} /&gt;
       )
  }
  </code></pre>
  
  <p>My question is if this is a good practice or should I send the client the binary data and render it on their end?</p>