title: Download PDF with laravel-dompdf with vuejs front-end
body: <p>I created an API with Laravel. I use Vuejs for the front end.</p>
  
  <p>I would like to generate a PDF based on the user and download it with view. Only, it does not work.</p>
  
  <p>Here is my controller:</p>
  
  <pre><code>public function generate($id)
      {
          $data = CoverLetter::where([
              ['id', '=', $id],
              ['user_id', '=', auth()-&gt;user()-&gt;id]
          ])-&gt;first();
  
          $path = public_path() . '/pdf/' . $data-&gt;filename . '.pdf';
  
          $pdf = PDF::loadView('pdf.coverletter', $data);
  
          $pdf-&gt;save($path);
  
          return response()-&gt;download($path);
      }
  </code></pre>
  
  <p>And my function in vue :</p>
  
  <pre><code>async downloadCoverLetter(file) {
     axios.get('/cover-letter/generate/' + file.id)
  }
  </code></pre>
  
  <p>And my button for download :</p>
  
  <pre><code>&lt;button @click="downloadCoverLetter(file)"&gt;&lt;/button&gt;
  </code></pre>
  
  <p>But it doesn't download at all. How to do ? Thank you !</p>