title: Get PDF out of arraybuffer in React Native
body: <p>The websocket on my server sends my react-native app an arraybuffer of a PDF and from there I'm trying to figure out how to display the PDF. I feel like <code>rn-fetch-blob</code> would be the answer but I'm not sure what goes where. On the browser, I just did this:</p>
  
  <pre><code>const pdfBlob = new Blob([e.data], {type: "application/pdf"})
  const url = URL.createObjectURL(pdfBlob);
  pdfViewer.setAttribute("src", url)
  </code></pre>
  
  <p>But React Native doesn't support making Blobs like that. My next attempt was doing something like this:</p>
  
  <pre><code>fetch(e.data, {
    responseType: "arraybuffer"
  })
    .then(res =&gt; res.arrayBuffer())
    .then(res =&gt; res.blob())
    .then(pdfBlob =&gt; {
      const url = URL.createObjectURL(pdfBlob);
      /** ... */
    })
    .catch(e =&gt; console.error(e));
  </code></pre>
  
  <p>But that didn't work either. I know <a href="https://stackoverflow.com/questions/38506971/react-native-populate-image-with-blob-that-has-been-converted-to-a-url">this guy</a> got it working for images when his response from the server was a blob, but I don't know if it's the same thing.</p>
  
  <p>I'm still super shakey on arraybuffers, blobs, fetching, etc. so any help is much appreciated.</p>