title: Download PDF from http response with Axios
body: <p>I am working on a Vue application with a Laravel back-end API. After clicking on a link I would like to do a call to the server to download a certain file (most of the time a PDF file). When I do a <code>get</code> request with <code>axios</code> I get a PDF in return, in the body of the response. I would like to download that file directly.</p>
  
  <p>To give you a better view of how the response is looking like:</p>
  
  <p><a href="https://i.stack.imgur.com/Z5ozo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Z5ozo.png" alt="enter image description here"></a>
  (note: I know a real text response is better than an image but I don't see any way to return that because of the length of the actual PDF content..)</p>
  
  <p>Is there any way of downloading that file with JavaScript or something? It has to be specific a direct download without clicking on the button again. </p>
  
  <p>Code</p>
  
  <pre><code>// This method gets called when clicking on a link
  downloadFile(id) {
      const specificationId = this.$route.params.specificationId;
  
      axios
          .get(`${this.$API_URL}/api/v1/suppliersmanagement/product-specifications/${specificationId}/fileupload/${id}/download`, {
              headers: this.headers,
          })
          .then(response =&gt; {
              console.log(response);
              // Direct download the file here..
          })
          .catch(error =&gt; console.log(error));
  },
  </code></pre>