title: How to consume the download stream from Axios using StreamSaver.js?
body: <p>On my server-side, which is built using Spring Boot framework, it returns a stream which looks like this:</p>
  <pre><code>public ResponseEntity&lt;StreamingResponseBody&gt; downloadFiles(@RequestBody DownloadRequest payload) {
  
      // Set proper header
      String contentDisposition = &quot;attachment;filename=download.zip&quot;;
  
      // Build the response stream
      StreamingResponseBody stream = outputStream -&gt; {
          archiveManagerService.downloadFiles(payload.getArchiveId(), payload.getFiles(), outputStream);
      };
  
      return ResponseEntity.ok()
              .contentType(MediaType.parseMediaType(&quot;application/zip&quot;))
              .header(HttpHeaders.CONTENT_DISPOSITION, contentDisposition)
              .body(stream);
  }
  </code></pre>
  <p>It works fine for me. I can download the file using Postman. Now, I need to call this endpoint <strong>from the client-side</strong> using <a href="https://github.com/axios/axios" rel="nofollow noreferrer">Axios</a>. After some searches, I found a library called <a href="https://github.com/jimmywarting/StreamSaver.js" rel="nofollow noreferrer">StreamSaver.js</a>. This library works fine with <a href="https://jimmywarting.github.io/StreamSaver.js/examples/fetch.html" rel="nofollow noreferrer">fetch</a> (view source to see the example code). However, I don't know how to use it with Axios.</p>
  <p>Currently, my code looks like this (I use Vuejs):</p>
  <pre><code>import axios from 'axios';
  import streamSaver from 'streamsaver';
  
  const instance = axios.create({
      baseURL: '&lt;my_base_url&gt;',
      headers: {
          'Content-Type': 'application/json'
      }
  });
  
  instance.post('/download', postData, {
      responseType: 'stream'
  })
  .then(response =&gt; {
      // What should I put here? These lines below don't work
      const fileStream = streamSaver.createWriteStream('download.zip');
      response.data.pipe(fileStream);
  });
  </code></pre>
  <p>I got an error saying that</p>
  <blockquote>
  <p>response.data.pipe is not a function</p>
  </blockquote>
  <p>So, how can I consume the stream from the client-side with Axios? Or maybe there is a better solution?</p>