title: Parse buffer image to base64 on React Native
body: <p>I am trying to show an image gotten from a server in a React Native app. What I am getting in the response look like this:</p>
  
  <p><a href="https://i.stack.imgur.com/WIfAu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WIfAu.png" alt="enter image description here"></a></p>
  
  <p>I tried to build a Buffer object using <a href="https://www.npmjs.com/package/buffer" rel="nofollow noreferrer">buffer</a> and then parse to base64</p>
  
  <pre><code>const imageBuffer = Buffer.from(JSON.stringify(res.data)) // This res.data is the whole object, including the type "Buffer" and the data array
  const imageBase64 = imageBuffer.toString('base64')
  setImage(imageBase64)
  </code></pre>
  
  <p>This returns a base64 image but it doesn't show using the React Native Image component</p>
  
  <pre><code>&lt;Image source={{ uri: `data:image/jpeg;base64,${image}` }} /&gt;
  </code></pre>
  
  <p>I didn't found how to handle images with this structure (a buffer as a numbers array) on React Native. I was thinking that maybe it is a way to do this without the library mentioned or without parse the buffer to a base64 but I don't know.</p>
  
  <p>Thank you</p>