title: Load pdf from server and embed in Vue app
body: <p>I have an api which returns a pdf file.  I'm trying to display this in vue.js and found the vue-pdf component which looks like it should do the job.  <a href="https://github.com/FranckFreiburger/vue-pdf" rel="noreferrer">Here's the project on github</a></p>
  <p>I'm able to call the API and get the binary response but I've not been able to convert the binary data into something which the vue-pdf library can display.</p>
  <p><a href="https://github.com/mozilla/pdf.js/blob/8ff1fbe7f819513e7d0023df961e3d223b35aefa/src/display/api.js#L117" rel="noreferrer">The documentation for the :src prop is here</a></p>
  <p>My vue code is below with a few of the failed attempts commented out.</p>
  <pre><code>&lt;template&gt;
    &lt;pdf :src=&quot;pdfsrc&quot;&gt;&lt;/pdf&gt;
  &lt;/template&gt;
  
  &lt;script&gt;
  import pdf from &quot;vue-pdf&quot;;
  import axios from &quot;axios&quot;;
  
  export default {
    components: {
      pdf
    },
    data() {
      return {
        pdfsrc: null
      };
    },
    created() {
      return axios
        .get(`${process.env.VUE_APP_API_INTRANET}/pdf`, {
          responseType: &quot;application/pdf&quot;
        })
        .then(response =&gt; {
          console.log(&quot;Success&quot;, response);
         
         // 1
         // this.pdfsrc = new Blob([response.data]);
         
         // 2
         //this.pdfsrc = response.data;
         
         //3
         //   for (var i = 0; i &lt; response.data.length; ++i) {
          //   this.pdfsrc.push(response.data.charCodeAt(i) &amp; 0xff);
          //   }
  
          //4
          this.pdfsrc = new Uint8Array(response.data);
        })
        .catch(console.error); //
    }
  };
  &lt;/script&gt;
  </code></pre>
  <p>I realise that for my example I could just set src to the URL of the api but ultimately it will need authorisation headers adding and chaining with OAuth calls so it needs to be an api call.</p>
  <p>I also want to display the pdf side by side with some data from another api call so using the trick of dynamically creating an anchor tag loaded with the data and .click() 'ing it won't work for me.</p>